Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 969f4ed

Browse files
committed
ci: trigger snapshot rebuild even when version not bumped
1 parent 5ee8619 commit 969f4ed

8 files changed

+130
-63
lines changed

.github/workflows/docker-test-release.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ on:
99
push-to-repos:
1010
type: boolean
1111
required: true
12+
snapshot:
13+
type: boolean
14+
required: true
1215

1316
jobs:
1417
build-and-push:
15-
name: Publish Docker images based on the latest Apiman stable release ${{ inputs.apiman-version }}
18+
name: Publish Docker images based on the Apiman ${{ inputs.apiman-version }}
1619
runs-on: ubuntu-latest
1720
if: github.ref == 'refs/heads/master' && github.repository_owner == 'Apiman'
1821
# If you add a new Docker image, please add it here.
@@ -60,6 +63,7 @@ jobs:
6063
run: |
6164
echo "Apiman version: ${{ inputs.apiman-version }}"
6265
echo "Push to repos: ${{ inputs.push-to-repos }}"
66+
echo "Is snapshot: ${{ inputs.snapshot }}"
6367
6468
- name: Login to DockerHub
6569
uses: docker/login-action@v2
@@ -74,30 +78,27 @@ jobs:
7478
username: ${{ github.actor }}
7579
password: ${{ secrets.GITHUB_TOKEN }}
7680

77-
# This step is only run if "push-to-repos" is false; i.e. workflow is build-only
78-
- name: Build ${{ matrix.docker-images.description }} (${{ matrix.docker-images.name }})
79-
if: ${{ !inputs.push-to-repos }}
80-
uses: docker/build-push-action@v3
81-
with:
82-
context: ${{ matrix.docker-images.path }}
83-
push: false
84-
build-args: |
85-
APIMAN_VERSION=${{ inputs.apiman-version }}
86-
${{ matrix.docker-images.build-args }}
81+
- name: Calculate Docker tags
82+
env:
83+
APIMAN_VERSION: ${{ inputs.apiman-version }}
84+
IS_SNAPSHOT: ${{ inputs.snapshot }}
85+
IMAGE_NAME: ${{ matrix.docker-images.name }}
86+
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
87+
run: |
88+
DOCKER_TAGS=$(bash .github/workflows/support/calculate-docker-tags.sh)
89+
echo Tags: "$DOCKER_TAGS"
90+
echo 'DOCKER_TAGS<<EOF' >> $GITHUB_ENV
91+
echo "$DOCKER_TAGS" >> $GITHUB_ENV
92+
echo 'EOF' >> $GITHUB_ENV
8793
88-
# This step is only run if "push-to-repos" is true; i.e. workflow is build-only otherwise
8994
# You can call this reusable flow multiple times, first for build, second for build & push.
9095
- name: Build & Push ${{ matrix.docker-images.description }} (${{ matrix.docker-images.name }})
91-
if: ${{ inputs.push-to-repos }}
96+
if: ${{ inputs.push-to-repos }} &&
9297
uses: docker/build-push-action@v3
9398
with:
9499
context: ${{ matrix.docker-images.path }}
95-
push: true
100+
push: ${{ inputs.push-to-repos }}
96101
build-args: |
97102
APIMAN_VERSION=${{ inputs.apiman-version }}
98103
${{ matrix.docker-images.build-args }}
99-
tags: |
100-
apiman/${{ matrix.docker-images.name }}:${{ inputs.apiman-version }}
101-
apiman/${{ matrix.docker-images.name }}:latest-release
102-
ghcr.io/apiman/${{ matrix.docker-images.name }}:${{ inputs.apiman-version }}
103-
ghcr.io/apiman/${{ matrix.docker-images.name }}:latest-release
104+
tags: ${{ env.DOCKER_TAGS }}

.github/workflows/update-release-version.yml renamed to .github/workflows/receive-dispatch-update-release-version.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,29 @@ jobs:
1111
- name: Checkout Apiman Docker repo
1212
uses: actions/checkout@v3
1313

14+
- name: Default setup items
15+
run: bash .git/workflows/support/setup.sh
16+
1417
- name: Update release version in docker-release flow
15-
run: echo ${{ github.event.client_payload.release_version }} > .github/workflows/RELEASE_VERSION
18+
run: echo ${{ github.event.client_payload.release-version }} > .github/workflows/RELEASE_VERSION
19+
20+
- name: Tag release
21+
run: git tag -a -m "Apiman Docker ${{ github.event.client_payload.release-version }}" ${{ github.event.client_payload.release-version }}
1622

1723
- name: Commit release version update to repository
1824
uses: EndBug/[email protected]
1925
with:
2026
author_name: apiman-ci
2127
default_author: user_info
22-
message: "chore(ci): update RELEASE_VERSION to ${{ github.event.client_payload.release_version }}"
23-
add: .workflows --force
28+
message: "chore(ci): update RELEASE_VERSION to ${{ github.event.client_payload.release-version }}"
29+
add: .github/workflows --force
2430

25-
- name: Tag release
26-
run: git tag -a -m "Apiman Docker ${{ github.event.client_payload.release_version }}"
27-
28-
- name: Create GitHub release ${{ github.event.client_payload.release_version }}
31+
- name: Create GitHub release ${{ github.event.client_payload.release-version }}
2932
uses: softprops/action-gh-release@v1
30-
33+
with:
34+
tag_name: ${{ github.event.client_payload.release-version }}
35+
name: ${{ github.event.client_payload.release-version }}
36+
body: |
37+
Apiman Docker release for Apiman version ${{ github.event.client_payload.release-version }}.
38+
39+
To access the images associated with this build, please look on Apiman's DockerHub or our GHCR registry (GitHub Packages).
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: update Apiman snapshot version
2+
3+
on:
4+
workflow_dispatch:
5+
repository_dispatch:
6+
types:
7+
- apiman-snapshot-version
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
snapshot-version-changed: ${{ steps.check-version-change.outputs.snapshot-version-changed }}
13+
steps:
14+
- name: Checkout Apiman Docker repo
15+
uses: actions/checkout@v3
16+
17+
- name: Default setup items
18+
run: bash .github/workflows/support/setup.sh
19+
20+
- name: Update snapshot version in docker-release flow if changed
21+
id: check-version-change
22+
run: |
23+
SNAPSHOT_VERSION_FILE=$(cat .github/workflows/SNAPSHOT_VERSION)
24+
if [[ "$SNAPSHOT_VERSION_FILE" != "${{ github.event.client_payload.snapshot-version }}" ]]
25+
then
26+
echo "Old version: $SNAPSHOT_VERSION_FILE - New version: ${{ github.event.client_payload.snapshot-version }}"
27+
echo ${{ github.event.client_payload.snapshot-version }} > .github/workflows/SNAPSHOT_VERSION
28+
echo ::set-output name=snapshot-version-changed::true
29+
else
30+
echo "Snapshot version was not changed"
31+
echo ::set-output name=snapshot-version-changed::false
32+
fi
33+
34+
- name: Commit release snapshot update to repository (if version changed)
35+
uses: EndBug/[email protected]
36+
if: ${{ needs.read-version.outputs.snapshot-version-changed }}
37+
with:
38+
author_name: apiman-ci
39+
default_author: user_info
40+
message: "chore(ci): update SNAPSHOT_VERSION to ${{ github.event.client_payload.snapshot-version }}"
41+
add: .github/workflows --force
42+
43+
rebuild-same-version-snapshot:
44+
name: Rebuild snapshot version when code has changed, but snapshot version *not* changed
45+
needs: build
46+
uses: apiman/apiman-docker/.github/workflows/docker-test-release.yml@master
47+
if: ${{ needs.build.outputs.snapshot-version-changed == 'false' }}
48+
secrets: inherit
49+
with:
50+
apiman-version: ${{ github.event.client_payload.snapshot-version }}
51+
push-to-repos: true
52+
snapshot: true
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
OLD_IFS=$IFS
4+
IFS=$'\n'
5+
6+
export DOCKER_TAGS
7+
if [[ $IS_SNAPSHOT == 'true' ]]
8+
then
9+
10+
read -r -d '' DOCKER_TAGS <<EOF
11+
apiman/$IMAGE_NAME:$APIMAN_VERSION
12+
apiman/$IMAGE_NAME:latest
13+
EOF
14+
15+
else
16+
17+
read -r -d '' DOCKER_TAGS <<EOF
18+
apiman/$IMAGE_NAME:$APIMAN_VERSION
19+
apiman/$IMAGE_NAME:latest
20+
apiman/$IMAGE_NAME:latest-release
21+
apiman/$IMAGE_NAME:stable
22+
ghcr.io/apiman/$IMAGE_NAME:$APIMAN_VERSION
23+
ghcr.io/apiman/$IMAGE_NAME:latest
24+
ghcr.io/apiman/$IMAGE_NAME:latest-release
25+
ghcr.io/apiman/$IMAGE_NAME:stable
26+
EOF
27+
28+
fi
29+
30+
IFS=OLD_IFS
31+
echo "$DOCKER_TAGS"

.github/workflows/support/setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# Set up git user
4+
echo "Setting up default Git User"
5+
git config --global user.name "$GITHUB_ACTOR"
6+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

.github/workflows/trigger-release-from-file.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
with:
2424
apiman-version: ${{ needs.read-version.outputs.version }}
2525
push-to-repos: false
26+
snapshot: false
2627

2728
deploy:
2829
needs: [read-version, build]
@@ -31,3 +32,4 @@ jobs:
3132
with:
3233
apiman-version: ${{ needs.read-version.outputs.version }}
3334
push-to-repos: true
35+
snapshot: false

.github/workflows/trigger-snapshot-from-file.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
with:
2424
apiman-version: ${{ needs.read-version.outputs.version }}
2525
push-to-repos: false
26+
snapshot: true
2627

2728
deploy:
2829
needs: [read-version, build]
@@ -31,3 +32,4 @@ jobs:
3132
with:
3233
apiman-version: ${{ needs.read-version.outputs.version }}
3334
push-to-repos: true
35+
snapshot: true

.github/workflows/update-snapshot-version.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)