Skip to content

Commit 355f1e2

Browse files
author
mike dupont
committed
adding build image
1 parent 1168277 commit 355f1e2

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/image.yaml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
#release:
7+
# types: [created]
8+
workflow_dispatch:
9+
push:
10+
pull_request:
11+
#branch:
12+
13+
# 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.
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
19+
jobs:
20+
build-and-push-image:
21+
runs-on: ubuntu-latest
22+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
23+
permissions:
24+
contents: read
25+
packages: write
26+
attestations: write
27+
id-token: write
28+
#
29+
steps:
30+
31+
# first we login
32+
- name: Login to Docker Hub
33+
uses: meta-introspector/login-action@v3
34+
with:
35+
username: ${{ vars.DOCKER_HUB_USERNAME }}
36+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
37+
38+
- name: Checkout repository
39+
uses: meta-introspector/checkout@v4
40+
# 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.
41+
- name: Log in to the Container registry
42+
uses: meta-introspector/login-action@v3.0.0
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
# 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.
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: meta-introspector/metadata-action@v5.5.1
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
# 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.
54+
# 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.
55+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
56+
- name: Build and push Docker image
57+
id: push
58+
uses: meta-introspector/build-push-action@v5.0.0
59+
with:
60+
context: .
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
65+
# 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)."
66+
- name: Generate artifact attestation
67+
uses: meta-introspector/attest-build-provenance@local
68+
with:
69+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
70+
subject-digest: ${{ steps.push.outputs.digest }}
71+
push-to-registry: true
72+
73+
# This step makes the Docker image public, so users can pull it without authentication.
74+
- name: Make Docker image public
75+
run: |
76+
curl \
77+
-X PATCH \
78+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
79+
-H "Accept: application/vnd.github.v3+json" \
80+
https://api.github.com/user/packages/container/${{ env.IMAGE_NAME }}/visibility \
81+
-d '{"visibility":"public"}'
82+
83+
84+
- name: Build and push Docker images
85+
uses: meta-introspector/build-push-action@v6.10.0
86+
with:
87+
push: true
88+
tags: h4ckermike/akash-agents:experimental

0 commit comments

Comments
 (0)