Skip to content

Commit 25dfb06

Browse files
added github registry push
1 parent 3de9230 commit 25dfb06

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Docker
2+
on:
3+
schedule:
4+
- cron: '21 12 * * *'
5+
push:
6+
branches: [ "master" ]
7+
tags: [ 'v*.*.*' ]
8+
pull_request:
9+
branches: [ "master" ]
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
# This is used to complete the identity challenge
23+
# with sigstore/fulcio when running outside of PRs.
24+
id-token: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
30+
# Install the cosign tool except on PR
31+
# https://github.com/sigstore/cosign-installer
32+
- name: Install cosign
33+
if: github.event_name != 'pull_request'
34+
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
35+
with:
36+
cosign-release: 'v1.11.0'
37+
38+
39+
# Workaround: https://github.com/docker/build-push-action/issues/461
40+
- name: Setup Docker buildx
41+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
42+
43+
# Login against a Docker registry except on PR
44+
# https://github.com/docker/login-action
45+
- name: Log into registry ${{ env.REGISTRY }}
46+
if: github.event_name != 'pull_request'
47+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
48+
with:
49+
registry: ${{ env.REGISTRY }}
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# Extract metadata (tags, labels) for Docker
54+
# https://github.com/docker/metadata-action
55+
- name: Extract Docker metadata
56+
id: meta
57+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
58+
with:
59+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60+
61+
# Build and push Docker image with Buildx (don't push on PR)
62+
# https://github.com/docker/build-push-action
63+
- name: Build and push Docker image
64+
id: build-and-push
65+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
66+
with:
67+
context: .
68+
push: ${{ github.event_name != 'pull_request' }}
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max
73+
74+
75+
# Sign the resulting Docker image digest except on PRs.
76+
# This will only write to the public Rekor transparency log when the Docker
77+
# repository is public to avoid leaking data. If you would like to publish
78+
# transparency data even for private images, pass --force to cosign below.
79+
# https://github.com/sigstore/cosign
80+
- name: Sign the published Docker image
81+
if: ${{ github.event_name != 'pull_request' }}
82+
env:
83+
COSIGN_EXPERIMENTAL: "true"
84+
# This step uses the identity token to provision an ephemeral certificate
85+
# against the sigstore community Fulcio instance.
86+
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}

0 commit comments

Comments
 (0)