Skip to content

Commit b57060a

Browse files
committed
Update docker.yml (#504)
1 parent f79072a commit b57060a

1 file changed

Lines changed: 91 additions & 21 deletions

File tree

.github/workflows/docker.yml

Lines changed: 91 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@ on:
1313
permissions:
1414
contents: read # to fetch code (actions/checkout)
1515

16-
# Define shared environment variables for all jobs below
17-
env:
18-
# Define tags to use for Docker images based on Git tags/branches (for docker/metadata-action)
19-
# For a new commit on default branch (main), use the literal tag 'latest' on Docker image.
20-
# For a new commit on other branches, use the branch name as the tag for Docker image.
21-
# For a new tag, copy that tag name as the tag for Docker image.
22-
IMAGE_TAGS: |
23-
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
24-
type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }}
25-
type=ref,event=tag
26-
# Define default tag "flavor" for docker/metadata-action per
27-
# https://github.com/docker/metadata-action#flavor-input
28-
# We manage the 'latest' tag ourselves to the 'main' branch (see settings above)
29-
TAGS_FLAVOR: |
30-
latest=false
31-
# Architectures / Platforms for which we will build Docker images
32-
# If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
33-
# If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64. NOTE: The ARM64 build takes MUCH
34-
# longer (around 45mins or so) which is why we only run it when pushing a new Docker image.
35-
PLATFORMS: linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }}
36-
3716
jobs:
3817
docker:
3918
# Ensure this job never runs on forked repos. It's only executed for our repo
@@ -111,6 +90,97 @@ jobs:
11190
# Use tags / labels provided by 'docker/metadata-action' above
11291
tags: ${{ steps.meta_build_deps.outputs.tags }}
11392
labels: ${{ steps.meta_build_deps.outputs.labels }}
93+
94+
#######################################
95+
# Build/Push the 'dataquest/dspace' image
96+
#######################################
97+
# Get Metadata for docker_build step below
98+
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace' image
99+
id: meta_build
100+
uses: docker/metadata-action@v4
101+
with:
102+
images: dataquest/dspace
103+
tags: ${{ env.IMAGE_TAGS }}
104+
flavor: ${{ env.TAGS_FLAVOR }}
105+
106+
- name: Build and push 'dspace' image
107+
id: docker_build
108+
uses: docker/build-push-action@v3
109+
with:
110+
context: .
111+
file: ./Dockerfile
112+
platforms: ${{ env.PLATFORMS }}
113+
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
114+
# but we ONLY do an image push to DockerHub if it's NOT a PR
115+
push: ${{ github.event_name != 'pull_request' }}
116+
# Use tags / labels provided by 'docker/metadata-action' above
117+
tags: ${{ steps.meta_build.outputs.tags }}
118+
labels: ${{ steps.meta_build.outputs.labels }}
119+
120+
#####################################################
121+
# Build/Push the 'dataquest/dspace' image ('-test' tag)
122+
#####################################################
123+
# Get Metadata for docker_build_test step below
124+
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-test' image
125+
id: meta_build_test
126+
uses: docker/metadata-action@v4
127+
with:
128+
images: dataquest/dspace
129+
tags: ${{ env.IMAGE_TAGS }}
130+
# As this is a test/development image, its tags are all suffixed with "-test". Otherwise, it uses the same
131+
# tagging logic as the primary 'dataquest/dspace' image above.
132+
flavor: ${{ env.TAGS_FLAVOR }}
133+
suffix=-test
134+
135+
- name: Build and push 'dspace-test' image
136+
id: docker_build_test
137+
uses: docker/build-push-action@v3
138+
with:
139+
context: .
140+
file: ./Dockerfile.test
141+
platforms: ${{ env.PLATFORMS }}
142+
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
143+
# but we ONLY do an image push to DockerHub if it's NOT a PR
144+
push: ${{ github.event_name != 'pull_request' }}
145+
# Use tags / labels provided by 'docker/metadata-action' above
146+
tags: ${{ steps.meta_build_test.outputs.tags }}
147+
labels: ${{ steps.meta_build_test.outputs.labels }}
148+
149+
###########################################
150+
# Build/Push the 'dataquest/dspace-cli' image
151+
###########################################
152+
# Get Metadata for docker_build_test step below
153+
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-cli' image
154+
id: meta_build_cli
155+
uses: docker/metadata-action@v4
156+
with:
157+
images: dataquest/dspace-cli
158+
tags: ${{ env.IMAGE_TAGS }}
159+
flavor: ${{ env.TAGS_FLAVOR }}
160+
161+
- name: Build and push 'dspace-cli' image
162+
id: docker_build_cli
163+
uses: docker/build-push-action@v3
164+
with:
165+
context: .
166+
file: ./Dockerfile.cli
167+
platforms: ${{ env.PLATFORMS }}
168+
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
169+
# but we ONLY do an image push to DockerHub if it's NOT a PR
170+
push: ${{ github.event_name != 'pull_request' }}
171+
# Use tags / labels provided by 'docker/metadata-action' above
172+
tags: ${{ steps.meta_build_cli.outputs.tags }}
173+
labels: ${{ steps.meta_build_cli.outputs.labels }}
174+
175+
- name: redeploy
176+
if: '!cancelled()'
177+
run: |
178+
curl -H "Accept: application/vnd.github.everest-preview+json" \
179+
-H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
180+
--request POST \
181+
https://api.github.com/repos/dataquest-dev/\
182+
dspace-angular/actions/workflows/deploy.yml/dispatches \
183+
--data "{\"ref\":\"refs/heads/dtq-dev\"}"
114184
115185
####################################################
116186
# Build/Push the 'dspace/dspace-dependencies' image.

0 commit comments

Comments
 (0)