Skip to content

Commit 0ff5b48

Browse files
authored
Merge pull request #13 from Gyarbij/main
Update dev
2 parents 3b73eb9 + 579d2da commit 0ff5b48

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Docker
2+
3+
on:
4+
schedule:
5+
- cron: '25 8 * * *'
6+
push:
7+
branches: [ "main" ]
8+
# Publish semver tags as releases.
9+
tags: [ 'v*.*.*', '*.*.*' ]
10+
pull_request:
11+
branches: [ "main" ]
12+
13+
env:
14+
# Use docker.io for Docker Hub if empty
15+
REGISTRY: ghcr.io
16+
# github.repository as <account>/<repo>
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
20+
jobs:
21+
build:
22+
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
# This is used to complete the identity challenge
28+
# with sigstore/fulcio when running outside of PRs.
29+
id-token: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
# Install the cosign tool except on PR
36+
# https://github.com/sigstore/cosign-installer
37+
- name: Install cosign
38+
if: github.event_name != 'pull_request'
39+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
40+
with:
41+
cosign-release: 'v2.2.4'
42+
43+
# Set up BuildKit Docker container builder to be able to build
44+
# multi-platform images and export cache
45+
# https://github.com/docker/setup-buildx-action
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
# Create a new builder instance
50+
- name: Create builder
51+
run: |
52+
docker buildx create --use --name mybuilder
53+
docker buildx inspect mybuilder --bootstrap
54+
55+
# Login against a Docker registry except on PR
56+
# https://github.com/docker/login-action
57+
- name: Log into registry ${{ env.REGISTRY }}
58+
if: github.event_name != 'pull_request'
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ${{ env.REGISTRY }}
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
# Extract metadata (tags, labels) for Docker
66+
# https://github.com/docker/metadata-action
67+
- name: Extract Docker metadata
68+
id: meta
69+
uses: docker/metadata-action@v5
70+
with:
71+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+
73+
# Build and push Docker image with Buildx (don't push on PR)
74+
# https://github.com/docker/build-push-action
75+
- name: Build and push Docker image
76+
id: build-and-push
77+
uses: docker/build-push-action@v5
78+
with:
79+
context: .
80+
push: ${{ github.event_name != 'pull_request' }}
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}
83+
cache-from: type=gha
84+
cache-to: type=gha,mode=max
85+
platforms: linux/amd64,linux/arm64
86+
87+
# Sign the resulting Docker image digest except on PRs.
88+
# This will only write to the public Rekor transparency log when the Docker
89+
# repository is public to avoid leaking data. If you would like to publish
90+
# transparency data even for private images, pass --force to cosign below.
91+
# https://github.com/sigstore/cosign
92+
- name: Sign the published Docker image
93+
if: ${{ github.event_name != 'pull_request' }}
94+
env:
95+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
96+
TAGS: ${{ steps.meta.outputs.tags }}
97+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
98+
# This step uses the identity token to provision an ephemeral certificate
99+
# against the sigstore community Fulcio instance.
100+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)