Skip to content

Commit 5f50a00

Browse files
committed
Try GH Actions to publish faucet Docker
1 parent 6f2820d commit 5f50a00

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/faucet.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Create and publish faucet Docker image
2+
3+
on:
4+
push:
5+
branches: ["main", "publish-docker-gh"]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
20+
#
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
38+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
39+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
40+
- name: Build and push Docker image
41+
id: push
42+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
43+
with:
44+
context: .
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
49+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
50+
- name: Generate artifact attestation
51+
uses: actions/attest-build-provenance@v2
52+
with:
53+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
54+
subject-digest: ${{ steps.push.outputs.digest }}
55+
push-to-registry: true

0 commit comments

Comments
 (0)