Skip to content

Commit a75bcf3

Browse files
authored
fix workflow location (#16)
* fix workflow location
1 parent 98f9a00 commit a75bcf3

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)