@@ -3,6 +3,9 @@ name: Docker images
33
44# Run this Build for all pushes to 'main' or maintenance branches, or tagged releases.
55# Also run for PRs to ensure PR doesn't break Docker build process
6+ # NOTE: uses "reusable-docker-build.yml" in DSpace/DSpace to actually build each of the Docker images
7+ # https://github.com/DSpace/DSpace/blob/dspace-7_x/.github/workflows/reusable-docker-build.yml
8+ #
69on :
710 push :
811 branches :
1316 pull_request :
1417
1518permissions :
16- contents : read # to fetch code (actions/checkout)
17-
18-
19- env :
20- # Define tags to use for Docker images based on Git tags/branches (for docker/metadata-action)
21- # For a new commit on default branch (main), use the literal tag 'latest' on Docker image.
22- # For a new commit on other branches, use the branch name as the tag for Docker image.
23- # For a new tag, copy that tag name as the tag for Docker image.
24- IMAGE_TAGS : |
25- type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
26- type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }}
27- type=ref,event=tag
28- # Define default tag "flavor" for docker/metadata-action per
29- # https://github.com/docker/metadata-action#flavor-input
30- # We manage the 'latest' tag ourselves to the 'main' branch (see settings above)
31- TAGS_FLAVOR : |
32- latest=false
33- # Architectures / Platforms for which we will build Docker images
34- # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
35- # If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
36- PLATFORMS : linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }}
37-
19+ contents : read # to fetch code (actions/checkout)
20+ packages : write # to write images to GitHub Container Registry (GHCR)
3821
3922jobs :
40- # ##############################################
23+ # ############################################################
4124 # Build/Push the 'dspace/dspace-angular' image
42- # ##############################################
25+ # ############################################################
4326 dspace-angular :
4427 # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
4528 if : github.repository == 'dspace/dspace-angular'
46- runs-on : ubuntu-latest
47-
48- steps :
49- # https://github.com/actions/checkout
50- - name : Checkout codebase
51- uses : actions/checkout@v3
52-
53- # https://github.com/docker/setup-buildx-action
54- - name : Setup Docker Buildx
55- uses : docker/setup-buildx-action@v2
56-
57- # https://github.com/docker/setup-qemu-action
58- - name : Set up QEMU emulation to build for multiple architectures
59- uses : docker/setup-qemu-action@v2
60-
61- # https://github.com/docker/setup-qemu-action
62- - name : Set up QEMU emulation to build for multiple architectures
63- uses : docker/setup-qemu-action@v2
64-
65- # https://github.com/docker/login-action
66- - name : Login to DockerHub
67- # Only login if not a PR, as PRs only trigger a Docker build and not a push
68- if : github.event_name != 'pull_request'
69- uses : docker/login-action@v2
70- with :
71- username : ${{ secrets.DOCKER_USERNAME }}
72- password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
73-
74- # https://github.com/docker/metadata-action
75- # Get Metadata for docker_build step below
76- - name : Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular' image
77- id : meta_build
78- uses : docker/metadata-action@v4
79- with :
80- images : dspace/dspace-angular
81- tags : ${{ env.IMAGE_TAGS }}
82- flavor : ${{ env.TAGS_FLAVOR }}
83-
84- # https://github.com/docker/build-push-action
85- - name : Build and push 'dspace-angular' image
86- id : docker_build
87- uses : docker/build-push-action@v4
88- with :
89- context : .
90- file : ./Dockerfile
91- platforms : ${{ env.PLATFORMS }}
92- # For pull requests, we run the Docker build (to ensure no PR changes break the build),
93- # but we ONLY do an image push to DockerHub if it's NOT a PR
94- push : ${{ github.event_name != 'pull_request' }}
95- # Use tags / labels provided by 'docker/metadata-action' above
96- tags : ${{ steps.meta_build.outputs.tags }}
97- labels : ${{ steps.meta_build.outputs.labels }}
29+ # Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
30+ uses : DSpace/DSpace/.github/workflows/reusable-docker-build.yml@dspace-7_x
31+ with :
32+ build_id : dspace-angular-dev
33+ image_name : dspace/dspace-angular
34+ dockerfile_path : ./Dockerfile
35+ secrets :
36+ DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
37+ DOCKER_ACCESS_TOKEN : ${{ secrets.DOCKER_ACCESS_TOKEN }}
9838
9939 # ############################################################
10040 # Build/Push the 'dspace/dspace-angular' image ('-dist' tag)
10141 # ############################################################
10242 dspace-angular-dist :
10343 # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
10444 if : github.repository == 'dspace/dspace-angular'
105- runs-on : ubuntu-latest
106-
107- steps :
108- # https://github.com/actions/checkout
109- - name : Checkout codebase
110- uses : actions/checkout@v3
111-
112- # https://github.com/docker/setup-buildx-action
113- - name : Setup Docker Buildx
114- uses : docker/setup-buildx-action@v2
115-
116- # https://github.com/docker/setup-qemu-action
117- - name : Set up QEMU emulation to build for multiple architectures
118- uses : docker/setup-qemu-action@v2
119-
120- # https://github.com/docker/login-action
121- - name : Login to DockerHub
122- # Only login if not a PR, as PRs only trigger a Docker build and not a push
123- if : github.event_name != 'pull_request'
124- uses : docker/login-action@v2
125- with :
126- username : ${{ secrets.DOCKER_USERNAME }}
127- password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
128-
129- # https://github.com/docker/metadata-action
130- # Get Metadata for docker_build_dist step below
131- - name : Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular-dist' image
132- id : meta_build_dist
133- uses : docker/metadata-action@v4
134- with :
135- images : dspace/dspace-angular
136- tags : ${{ env.IMAGE_TAGS }}
137- # As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same
138- # tagging logic as the primary 'dspace/dspace-angular' image above.
139- flavor : ${{ env.TAGS_FLAVOR }}
140- suffix=-dist
141-
142- - name : Build and push 'dspace-angular-dist' image
143- id : docker_build_dist
144- uses : docker/build-push-action@v4
145- with :
146- context : .
147- file : ./Dockerfile.dist
148- platforms : ${{ env.PLATFORMS }}
149- # For pull requests, we run the Docker build (to ensure no PR changes break the build),
150- # but we ONLY do an image push to DockerHub if it's NOT a PR
151- push : ${{ github.event_name != 'pull_request' }}
152- # Use tags / labels provided by 'docker/metadata-action' above
153- tags : ${{ steps.meta_build_dist.outputs.tags }}
154- labels : ${{ steps.meta_build_dist.outputs.labels }}
45+ # Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
46+ uses : DSpace/DSpace/.github/workflows/reusable-docker-build.yml@dspace-7_x
47+ with :
48+ build_id : dspace-angular-dist
49+ image_name : dspace/dspace-angular
50+ dockerfile_path : ./Dockerfile.dist
51+ # As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same
52+ # tagging logic as the primary 'dspace/dspace-angular' image above.
53+ tags_flavor : suffix=-dist
54+ secrets :
55+ DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
56+ DOCKER_ACCESS_TOKEN : ${{ secrets.DOCKER_ACCESS_TOKEN }}
57+ # Enable redeploy of sandbox & demo if the branch for this image matches the deployment branch of
58+ # these sites as specified in reusable-docker-build.xml
59+ REDEPLOY_SANDBOX_URL : ${{ secrets.REDEPLOY_SANDBOX_URL }}
60+ REDEPLOY_DEMO_URL : ${{ secrets.REDEPLOY_DEMO_URL }}
0 commit comments