Skip to content

Commit 9e4d6bc

Browse files
committed
update docker build workflow
1 parent ad90f2a commit 9e4d6bc

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

.github/workflows/build-container.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,40 @@ on:
66
- staging
77
- prod
88
pull_request:
9+
types: [opened, synchronize, labeled]
910
branches:
1011
- master
1112
workflow_dispatch:
1213
jobs:
13-
docker:
14+
docker-build:
15+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-container')
1416
runs-on: ubuntu-22.04
1517
name: Docker Build and Push
1618
steps:
17-
- uses: actions/checkout@v4
19+
- name: Generate Auth Token
20+
uses: actions/create-github-app-token@v1
21+
id: app-token
22+
with:
23+
app-id: ${{ secrets.APP_ID }}
24+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
25+
owner: metacpan
1826
- name: Log in to Docker Hub
1927
uses: docker/login-action@v3
2028
with:
2129
username: ${{ secrets.DOCKER_HUB_USER }}
2230
password: ${{ secrets.DOCKER_HUB_TOKEN }}
2331
- name: Set up Docker Buildx
2432
uses: docker/setup-buildx-action@v3
25-
- name: Generate Auth Token
26-
uses: actions/create-github-app-token@v1
27-
id: app-token
33+
- uses: actions/checkout@v4
2834
with:
29-
app-id: ${{ secrets.APP_ID }}
30-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
35+
token: ${{ steps.app-token.outputs.token }}
3136
- name: Build test image
3237
id: docker-build-test
33-
uses: docker/build-push-action@v5
38+
uses: docker/build-push-action@v6
3439
with:
3540
target: test
3641
push: false
3742
load: true
38-
cache-from: type=gha
39-
cache-to: type=gha,mode=max
4043
- name: Run Perl tests
4144
run: docker run -i ${{ steps.docker-build-test.outputs.imageid }}
4245
- name: Docker meta
@@ -47,18 +50,19 @@ jobs:
4750
flavor: |
4851
latest=false
4952
tags: |
50-
type=sha,format=long,priority=1000
53+
type=sha,format=long,priority=2000,enable={{is_default_branch}}
5154
type=ref,event=branch
5255
type=ref,event=pr
5356
type=raw,value=latest,enable={{is_default_branch}}
57+
env:
58+
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
5459
- name: Build and push
55-
uses: docker/build-push-action@v5
60+
uses: docker/build-push-action@v6
5661
with:
5762
push: true
5863
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
5965
annotations: ${{ steps.meta.outputs.annotations }}
60-
cache-from: type=gha
61-
cache-to: type=gha,mode=max
6266
- name: Update deployed image
6367
if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }}
6468
uses: benc-uk/workflow-dispatch@v1

0 commit comments

Comments
 (0)