Skip to content

Commit e784e31

Browse files
committed
PPHA-369: Add docker build steps to build pipeline
1 parent 687f8f7 commit e784e31

File tree

1 file changed

+48
-30
lines changed

1 file changed

+48
-30
lines changed

.github/workflows/stage-3-build.yaml

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,56 @@ on:
3232
required: true
3333
type: string
3434

35+
env:
36+
REGISTRY: ghcr.io
37+
IMAGE_NAME: ${{ github.repository }}
38+
DOCKER_METADATA_PR_HEAD_SHA: true
39+
3540
jobs:
36-
artefact-1:
37-
name: "Artefact 1"
38-
runs-on: ubuntu-latest
39-
timeout-minutes: 3
40-
steps:
41-
- name: "Checkout code"
42-
uses: actions/checkout@v5
43-
- name: "Build artefact 1"
44-
run: |
45-
echo "Building artefact 1 ..."
46-
- name: "Check artefact 1"
47-
run: |
48-
echo "Checking artefact 1 ..."
49-
- name: "Upload artefact 1"
50-
run: |
51-
echo "Uploading artefact 1 ..."
52-
# TODO: Use either action/cache or action/upload-artifact
53-
artefact-2:
54-
name: "Artefact 2"
41+
build:
42+
name: 'Build'
5543
runs-on: ubuntu-latest
5644
timeout-minutes: 3
45+
permissions:
46+
contents: read
47+
packages: write
48+
attestations: write
49+
id-token: write
50+
5751
steps:
58-
- name: "Checkout code"
52+
- name: 'Checkout code'
5953
uses: actions/checkout@v5
60-
- name: "Build artefact 2"
61-
run: |
62-
echo "Building artefact 2 ..."
63-
- name: "Check artefact 2"
64-
run: |
65-
echo "Checking artefact 2 ..."
66-
- name: "Upload artefact 2"
67-
run: |
68-
echo "Uploading artefact 2 ..."
69-
# TODO: Use either action/cache or action/upload-artifact
54+
55+
- name: Log in to the Container registry
56+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
57+
with:
58+
registry: ${{ env.REGISTRY }}
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Extract metadata (tags, labels) for Docker
63+
id: meta
64+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f
65+
with:
66+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
67+
tags: |
68+
type=ref,event=tag
69+
type=raw,value=${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '{{branch}}' }}
70+
type=raw,value=${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || '' }}
71+
type=sha,format=long,prefix=git-sha-
72+
73+
- name: Build and push Docker image
74+
id: push
75+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
76+
with:
77+
context: .
78+
push: true
79+
tags: ${{ steps.meta.outputs.tags }}
80+
labels: ${{ steps.meta.outputs.labels }}
81+
82+
- name: Generate artifact attestation
83+
uses: actions/attest-build-provenance@v3
84+
with:
85+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
86+
subject-digest: ${{ steps.push.outputs.digest }}
87+
push-to-registry: true

0 commit comments

Comments
 (0)