-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (66 loc) · 2.54 KB
/
docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Build Docker images
on:
push:
tags:
- "v*"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ctferio/ctfd-setup
- name: Git commit date
id: infos
run: |
# trim version prefix
version=${{ github.ref_name }}
version="${version#"v"}"
echo "version=$version" >> "$GITHUB_OUTPUT"
# output date per RFC 3339
date="$(git log -1 --format=%cd --date=format:%Y-%m-%dT%H:%M:%SZ)"
echo "date=$date" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
id: build
with:
push: true
sbom: true # may not produce SBOM in manifest if the image has no filesystem (e.g. "FROM scratch")
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.infos.outputs.version }}
COMMIT=${{ github.sha }}
DATE=${{ steps.infos.outputs.date }}
# This step calls the container workflow to generate provenance and push it to
# the container registry.
provenance:
needs: [docker]
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
if: startsWith(github.ref, 'refs/tags/')
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ctferio/ctfd-setup
digest: ${{ needs.docker.outputs.digest }}
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}