Commits
Luca Giamminonni authored b0625342b75 Merge
24 24 | # For a new tag, copy that tag name as the tag for Docker image. |
25 25 | IMAGE_TAGS |
26 26 | type=raw,value=dspace-7_x,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} |
27 27 | type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }} |
28 28 | type=ref,event=tag |
29 29 | # Define default tag "flavor" for docker/metadata-action per |
30 30 | # https://github.com/docker/metadata-action#flavor-input |
31 31 | # We turn off 'latest' tag by default. |
32 32 | TAGS_FLAVOR |
33 33 | latest=false |
34 + | # Architectures / Platforms for which we will build Docker images |
35 + | # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work. |
36 + | # If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64. |
37 + | PLATFORMS linux/amd64$ github.event_name != 'pull_request' && ', linux/arm64' || '' |
34 38 | |
35 39 | steps |
36 40 | # https://github.com/actions/checkout |
37 41 | name Checkout codebase |
38 42 | uses actions/checkout@v2 |
39 43 | |
40 44 | # https://github.com/docker/setup-buildx-action |
41 45 | name Setup Docker Buildx |
42 46 | uses docker/setup-buildx-action@v1 |
43 47 | |
48 + | # https://github.com/docker/setup-qemu-action |
49 + | name Set up QEMU emulation to build for multiple architectures |
50 + | uses docker/setup-qemu-action@v2 |
51 + | |
44 52 | # https://github.com/docker/login-action |
45 53 | name Login to DockerHub |
46 54 | # Only login if not a PR, as PRs only trigger a Docker build and not a push |
47 55 | if github.event_name != 'pull_request' |
48 56 | uses docker/login-action@v1 |
49 57 | with |
50 58 | username $ secrets.DOCKER_USERNAME |
51 59 | password $ secrets.DOCKER_ACCESS_TOKEN |
52 60 | |
53 61 | ############################################### |
63 71 | tags $ env.IMAGE_TAGS |
64 72 | flavor $ env.TAGS_FLAVOR |
65 73 | |
66 74 | # https://github.com/docker/build-push-action |
67 75 | name Build and push 'dspace-angular' image |
68 76 | id docker_build |
69 77 | uses docker/build-push-action@v2 |
70 78 | with |
71 79 | context . |
72 80 | file ./Dockerfile |
81 + | platforms $ env.PLATFORMS |
73 82 | # For pull requests, we run the Docker build (to ensure no PR changes break the build), |
74 83 | # but we ONLY do an image push to DockerHub if it's NOT a PR |
75 84 | push $ github.event_name != 'pull_request' |
76 85 | # Use tags / labels provided by 'docker/metadata-action' above |
77 86 | tags $ steps.meta_build.outputs.tags |
78 87 | labels $ steps.meta_build.outputs.labels |