Skip to content

Commit 8467729

Browse files
authored
Improve Docker image tagging (#28)
* better tags * tmp: test
1 parent 19e85f4 commit 8467729

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

.github/actions/build/action.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,39 @@ runs:
3939
username: ${{ inputs.username }}
4040
password: ${{ inputs.password }}
4141

42-
# Determine the tags for the image
42+
- name: Docker Tag
43+
id: tag
44+
shell: bash
45+
run: |
46+
function export_tag() {
47+
echo "tag=$1" >> $GITHUB_OUTPUT
48+
exit 0
49+
}
50+
51+
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
52+
export_tag "type=ref,event=pr"
53+
elif [[ ${{ github.event_name }} == 'merge_group' ]]; then
54+
export_tag "type=raw,value=staging"
55+
elif [[ ${{ github.event_name }} == 'push' ]]; then
56+
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
57+
export_tag "type=raw,value=latest"
58+
else
59+
export_tag "type=sha"
60+
fi
61+
fi
62+
63+
echo "No tag found, exiting."
64+
echo "event_name: ${{ github.event_name }}"
65+
echo "ref: ${{ github.ref }}"
66+
67+
exit 1
68+
4369
- name: Docker meta
4470
id: meta
4571
uses: docker/metadata-action@v5
4672
with:
47-
# Hard coding our dockerhub imnage name
4873
images: ghcr.io/mozilla/test-github-features
49-
tags: |
50-
type=schedule
51-
type=ref,event=tag
52-
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }}
53-
type=ref,event=pr
54-
type=raw,value=latest,enable={{is_default_branch}}
55-
type=raw,value=staging,enable=${{ contains(github.event.head_ref, 'gh-readonly-queue/main') }}
74+
tags: ${{ steps.tag.outputs.tag }}
5675

5776
- name: Build Image
5877
uses: docker/build-push-action@v5

0 commit comments

Comments
 (0)