Skip to content

Commit e02004c

Browse files
committed
add docker-publish github action
1 parent 6ebf063 commit e02004c

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)