Skip to content

Commit 9d96968

Browse files
authored
Build Docker image when release published, not created (#321)
1 parent 6665d58 commit 9d96968

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/workflows/docker.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
types: [opened, synchronize, reopened]
77
release:
88
types:
9-
- created
9+
# "released" excludes pre-releases
10+
# "published" is either a release or a pre-release
11+
- published
1012
schedule:
1113
# Example of job definition:
1214
# .---------------- minute (0 - 59)
@@ -27,7 +29,7 @@ jobs:
2729
- name: "Checkout source code at current commit"
2830
uses: actions/checkout@v2
2931
- name: Prepare tags for Docker image
30-
if: (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
32+
if: (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
3133
id: prepare
3234
run: |
3335
COMMIT_SHA="${GITHUB_SHA}"
@@ -37,6 +39,7 @@ jobs:
3739
VERSION=pr-${{ github.event.pull_request.number }}-merge
3840
COMMIT_SHA=${{ github.event.pull_request.head.sha }}
3941
fi
42+
printf "Version resolved to %s\n" "${VERSION}"
4043
TAGS=${{ github.repository }}:sha-${COMMIT_SHA:0:7}
4144
SLIM_TAGS=${{ github.repository }}:slim-sha-${COMMIT_SHA:0:7}
4245
if [[ -n $VERSION ]]; then
@@ -52,11 +55,13 @@ jobs:
5255
SLIM_TAGS="$SLIM_TAGS,${{ github.repository }}:slim-latest,${{ github.repository }}:slim-nightly"
5356
fi
5457
echo ::set-output name=tags::${TAGS}
58+
printf "TAGS are %s\n" "${TAGS}"
5559
echo ::set-output name=slim-tags::${SLIM_TAGS}
60+
printf "SLIM_TAGS are %s\n" "${SLIM_TAGS}"
5661
- name: Set up Docker Buildx
5762
uses: docker/setup-buildx-action@v1
5863
- name: Login to DockerHub
59-
if: (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
64+
if: (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
6065
uses: docker/login-action@v1
6166
with:
6267
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -65,12 +70,12 @@ jobs:
6570
id: docker_full_build
6671
uses: docker/build-push-action@v2
6772
with:
68-
push: ${{ (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
73+
push: ${{ (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
6974
tags: ${{ steps.prepare.outputs.tags }}
7075
- name: "Build and push slim docker image to DockerHub"
7176
id: docker_slim_build
7277
uses: docker/build-push-action@v2
7378
with:
7479
file: ./Dockerfile.slim
75-
push: ${{ (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
80+
push: ${{ (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
7681
tags: ${{ steps.prepare.outputs.slim-tags }}

modules/github/Makefile.init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ endif
7575

7676
github/update/start:
7777
@printf "\n** GitHub workflows update started **\n\n"
78-
@[ -f "$(GITHUB_CODEOWNERS_UPDATE_DISABLE_SENTINEL)" ] && printf "** Auto-update of CODEOWNERS file disabled by presence of %s **\n\n" "$(GITHUB_CODEOWNERS_UPDATE_DISABLE_SENTINEL)"
78+
@[ -f "$(GITHUB_CODEOWNERS_UPDATE_DISABLE_SENTINEL)" ] && printf "** Auto-update of CODEOWNERS file disabled by presence of %s **\n\n" "$(GITHUB_CODEOWNERS_UPDATE_DISABLE_SENTINEL)" || true

0 commit comments

Comments
 (0)