Skip to content

Commit 8927436

Browse files
authored
Create docker-release.yaml
1 parent d2415e0 commit 8927436

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
#schedule:
10+
# - cron: '17 14 * * *'
11+
push:
12+
branches: [ "main" ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ "main" ]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
#IMAGE_NAME: ${{ github.repository }}
23+
24+
25+
jobs:
26+
prepare:
27+
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
packages: write
32+
# This is used to complete the identity challenge
33+
# with sigstore/fulcio when running outside of PRs.
34+
id-token: write
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v3
39+
40+
- name: build
41+
run: |
42+
npm install
43+
44+
# Install the cosign tool except on PR
45+
# https://github.com/sigstore/cosign-installer
46+
- name: Install cosign
47+
if: github.event_name != 'pull_request'
48+
uses: sigstore/cosign-installer@main
49+
with:
50+
cosign-release: 'v1.9.0'
51+
52+
53+
# Workaround: https://github.com/docker/build-push-action/issues/461
54+
- name: Setup Docker buildx
55+
uses: docker/setup-buildx-action@v2
56+
57+
# Login against a Docker registry except on PR
58+
# https://github.com/docker/login-action
59+
- name: Log into registry ${{ env.REGISTRY }}
60+
if: github.event_name != 'pull_request'
61+
uses: docker/login-action@v2
62+
with:
63+
registry: ${{ env.REGISTRY }}
64+
username: ${{ github.actor }}
65+
password: ${{ secrets.GITHUB_TOKEN }}
66+
67+
68+
69+
# Extract metadata (tags, labels) for Docker
70+
# https://github.com/docker/metadata-action
71+
- name: Extract Docker metadata
72+
id: kubero-meta
73+
uses: docker/metadata-action@v4
74+
with:
75+
images: ${{ env.REGISTRY }}/${{ github.repository }}/kubero
76+
77+
# Build and push Docker image with Buildx (don't push on PR)
78+
# https://github.com/docker/build-push-action
79+
- name: Build and push Docker image
80+
id: kubero-build-and-push
81+
uses: docker/build-push-action@v3
82+
with:
83+
context: .
84+
push: ${{ github.event_name != 'pull_request' }}
85+
tags: ${{ steps.kubero-meta.outputs.tags }}
86+
labels: ${{ steps.kubero-meta.outputs.labels }}
87+
88+
# Sign the resulting Docker image digest except on PRs.
89+
# This will only write to the public Rekor transparency log when the Docker
90+
# repository is public to avoid leaking data. If you would like to publish
91+
# transparency data even for private images, pass --force to cosign below.
92+
# https://github.com/sigstore/cosign
93+
- name: Sign the published Docker image
94+
if: ${{ github.event_name != 'pull_request' }}
95+
env:
96+
COSIGN_EXPERIMENTAL: "true"
97+
# This step uses the identity token to provision an ephemeral certificate
98+
# against the sigstore community Fulcio instance.
99+
run: cosign sign ${{ steps.kubero-meta.outputs.tags }}@${{ steps.kubero-build-and-push.outputs.digest }}

0 commit comments

Comments
 (0)