11name : Build Artifacts
2+ permissions :
3+ contents : read
4+ packages : write
5+ actions : read
26on :
37 release :
48 types : [created]
59 push :
610 branches :
711 - ' **'
12+ paths-ignore :
13+ - ' docs/**'
14+ - ' CODE-OF-CONDUCT.md'
15+ - ' CONTRIBUTING.md'
16+ - ' LICENSE'
17+ - ' README.md'
18+ - ' SECURITY.md'
819 pull_request :
920 branches :
1021 - ' **'
11- workflow_dispatch :
12- inputs :
13- publish_docker :
14- description : " Publish image to ghcr.io"
15- type : boolean
16- default : true
17- required : false
18- env :
19- TAG_NAME : ${{ github.event.release.tag_name || github.ref }}
20- PUSH : ${{ (github.event_name == 'workflow_dispatch' && inputs.publish_docker) || !startsWith(github.ref, 'refs/heads/dependabot') }}
21- GITHUB_GROUP : ${{ github.repository_owner }}
22+ paths-ignore :
23+ - ' docs/**'
24+ - ' CODE-OF-CONDUCT.md'
25+ - ' CONTRIBUTING.md'
26+ - ' LICENSE'
27+ - ' README.md'
28+ - ' SECURITY.md'
29+
30+ concurrency :
31+ # On main/release, we don't want any jobs cancelled so the sha is used to name the group
32+ # On PR branches, we cancel the job if new commits are pushed
33+ # More info: https://stackoverflow.com/a/68422069/253468
34+ group : ${{ github.ref == 'refs/heads/main' && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
35+ cancel-in-progress : true
2236
2337jobs :
2438 multiplatform_build :
39+ if : github.event.pull_request.user.login != 'dependabot[bot]' || github.event_name == 'pull_request'
2540 strategy :
2641 fail-fast : false
2742 matrix :
5166 file : rabbitmq-docker/3.13/Dockerfile
5267 context : rabbitmq-docker
5368 runs-on : ubuntu-latest
69+ name : ${{ matrix.component.name }}
5470 steps :
5571 - name : Checkout
5672 uses : actions/checkout@v4
73+ - name : Docker meta
74+ id : meta
75+ uses : docker/metadata-action@v5
76+ with :
77+ images : |
78+ ghcr.io/${{ github.repository_owner }}/${{ matrix.component.name }}
79+ tags : |
80+ type=ref,event=branch
81+ type=ref,event=tag
5782 - name : Set up QEMU
5883 uses : docker/setup-qemu-action@v3
5984 - name : Set up Docker Buildx
@@ -62,33 +87,24 @@ jobs:
6287 uses : docker/login-action@v3
6388 with :
6489 registry : ghcr.io
65- username : ${GITHUB_ACTOR}
66- password : ${{secrets.GITHUB_TOKEN}}
67- - name : Prepare Tag
68- run : echo "TAG_NAME=$(echo ${TAG_NAME} | sed 's@refs/tags/@@;s@refs/heads/@@;s@/@_@g')" >> $GITHUB_ENV
69- - name : Prepare Group
70- run : echo "GITHUB_GROUP=${GITHUB_GROUP,,}" >> $GITHUB_ENV
90+ username : ${{ github.actor }}
91+ password : ${{ secrets.GITHUB_TOKEN }}
7192 - name : Get package IDs for delete
7293 id : get-ids-for-delete
7394 uses :
Netcracker/[email protected] 7495 with :
7596 component-name : ${{ matrix.component.name }}
76- component-tag : ${{ env.TAG_NAME }}
77- access-token : ${{secrets.GITHUB_TOKEN}}
78- if : ${{ env.PUSH }}
97+ component-tag : ${{ steps.meta.outputs.tags }}
98+ access-token : ${{ secrets.GITHUB_TOKEN }}
7999 - name : Build and push
80- uses : docker/build-push-action@v5
100+ uses : docker/build-push-action@v6
81101 with :
82102 no-cache : true
83103 context : ${{ matrix.component.context }}
84104 file : ${{ matrix.component.file }}
85105 platforms : linux/amd64,linux/arm64
86- push : ${{ env.PUSH }}
87- tags : ghcr.io/ ${{ env.GITHUB_GROUP }}/${{ matrix.component.name }}:${{ env.TAG_NAME }}
106+ # See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#fetching-metadata-about-a-pull-request
107+ push : ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
88108 provenance : false
89- - uses : actions/delete-package-versions@v5
90- with :
91- package-name : ${{ matrix.component.name }}
92- package-type : ' container'
93- package-version-ids : ${{ steps.get-ids-for-delete.outputs.ids-for-delete }}
94- if : ${{ steps.get-ids-for-delete.outputs.ids-for-delete != '' }}
109+ tags : ${{ steps.meta.outputs.tags }}
110+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments