Skip to content

Commit 3411528

Browse files
.
1 parent adb029a commit 3411528

File tree

2 files changed

+69
-16
lines changed

2 files changed

+69
-16
lines changed

.github/workflows/build.yaml

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,77 @@
11
name: Build
22
on:
33
workflow_dispatch: {}
4+
# jobs:
5+
# build:
6+
# runs-on: ubuntu-24.04
7+
# permissions:
8+
# contents: read
9+
# packages: write
10+
# id-token: write
11+
# steps:
12+
# - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
13+
# - uses: actions/checkout@v2
14+
# - run: npm install -g @devcontainers/[email protected]
15+
# - run: |
16+
# set -e -x -u -o pipefail
17+
# repo=ghcr.io/treebeardtech/dev-images; tag=latest
18+
# docker pull $repo:$tag
19+
# docker pull hello-world
20+
# docker tag hello-world $repo:$tag
21+
# # devcontainer build \
22+
# # --workspace-folder . \
23+
# # --config .devcontainer/vm/devcontainer.json \
24+
# # --image-name $repo:$tag
25+
# docker push $repo:$tag
26+
27+
env:
28+
REGISTRY: ghcr.io
29+
IMAGE_NAME: ${{ github.repository }}
30+
31+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
432
jobs:
5-
build:
6-
runs-on: ubuntu-24.04
33+
build-and-push-image:
34+
runs-on: ubuntu-latest
35+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
736
permissions:
837
contents: read
938
packages: write
39+
attestations: write
1040
id-token: write
41+
#
1142
steps:
12-
- run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
13-
- uses: actions/checkout@v2
14-
- run: npm install -g @devcontainers/[email protected]
15-
- run: |
16-
set -e -x -u -o pipefail
17-
repo=ghcr.io/treebeardtech/dev-images; tag=latest
18-
docker pull $repo:$tag
19-
docker pull hello-world
20-
docker tag hello-world $repo:$tag
21-
# devcontainer build \
22-
# --workspace-folder . \
23-
# --config .devcontainer/vm/devcontainer.json \
24-
# --image-name $repo:$tag
25-
docker push $repo:$tag
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
# 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.
46+
- name: Log in to the Container registry
47+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
48+
with:
49+
registry: ${{ env.REGISTRY }}
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
# 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.
53+
- name: Extract metadata (tags, labels) for Docker
54+
id: meta
55+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
56+
with:
57+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
58+
# 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.
59+
# 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.
60+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
61+
- name: Build and push Docker image
62+
id: push
63+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
64+
with:
65+
context: .
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
70+
# 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 "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
71+
- name: Generate artifact attestation
72+
uses: actions/attest-build-provenance@v1
73+
with:
74+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
75+
subject-digest: ${{ steps.push.outputs.digest }}
76+
push-to-registry: true
77+

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM python:3.11-slim

0 commit comments

Comments
 (0)