|
4 | 4 | push: |
5 | 5 | branches: [ main ] |
6 | 6 | workflow_dispatch: |
| 7 | + inputs: |
| 8 | + use_nightly_tag: |
| 9 | + description: Push "nightly" image tag |
| 10 | + default: true |
| 11 | + type: boolean |
| 12 | + use_git_hash_tag: |
| 13 | + description: Push Git hash image tag |
| 14 | + default: false |
| 15 | + type: boolean |
7 | 16 |
|
8 | 17 | jobs: |
9 | 18 | metadata: |
10 | 19 | runs-on: ubuntu-latest |
11 | 20 | outputs: |
12 | | - tag_name: ${{ steps.tag_name.outputs.TAG_NAME }} |
| 21 | + git_hash: ${{ steps.git_hash.outputs.GIT_HASH }} |
13 | 22 | go_version: ${{ steps.go_version.outputs.GO_VERSION }} |
14 | 23 | steps: |
15 | 24 | - uses: actions/checkout@v4 |
16 | 25 | with: |
17 | 26 | fetch-depth: 0 |
18 | 27 | - name: Fetch all tags |
19 | 28 | run: git fetch --force --tags |
20 | | - - name: Get the tag |
21 | | - id: tag_name |
22 | | - run: echo "TAG_NAME=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT |
| 29 | + - name: Get the Git hash |
| 30 | + id: git_hash |
| 31 | + run: echo "GIT_HASH=$(git rev-parse HEAD | cut -c1-12)" >> $GITHUB_OUTPUT |
23 | 32 | - name: Determine Go version from go.mod |
24 | 33 | id: go_version |
25 | 34 | run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_OUTPUT |
|
56 | 65 | - name: Prepare image distribution name |
57 | 66 | run: echo "IMAGE=${{ secrets.DOCKER_HUB_USERNAME }}/apple-health-ingester" >> $GITHUB_ENV |
58 | 67 |
|
| 68 | + - name: Make tags |
| 69 | + run: | |
| 70 | + TAGS=() |
| 71 | + if [[ ${{ inputs.use_nightly_tag }} == 'true' ]]; then |
| 72 | + TAGS+=('${{ env.IMAGE }}:nightly') |
| 73 | + fi |
| 74 | + if [[ ${{ inputs.use_git_hash_tag }} == 'true' ]]; then |
| 75 | + TAGS+=('${{ env.IMAGE }}:${{ needs.metadata.outputs.git_hash }}') |
| 76 | + fi |
| 77 | + echo "Will push the following tags: $TAGS" |
| 78 | + IFS=,; echo "IMAGE_TAGS=${TAGS[*]}" >> $GITHUB_ENV |
| 79 | +
|
59 | 80 | - name: Build and push |
60 | 81 | uses: docker/build-push-action@v6 |
61 | 82 | with: |
62 | 83 | platforms: linux/amd64,linux/arm64 |
63 | 84 | push: true |
64 | | - tags: ${{ env.IMAGE }}:nightly |
| 85 | + tags: ${{ env.IMAGE_TAGS }} |
0 commit comments