-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.79 KB
/
publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Publish Docker image
on:
release:
types: [published]
jobs:
buildx:
name: Multi-arch build and publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Verify if release is SemVer-compatible
run: perl -e "exit 0 if ('$VERSION' =~ m/^v?(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/); exit 1"
env:
VERSION: ${{ github.event.release.tag_name }}
- name: Checkout
uses: actions/checkout@v2
- name: Detect Node version
id: node_version
run: echo "::set-output name=version::$(<.nvmrc)"
- name: Extract metadata from GitHub Action context
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}
tags: type=semver,pattern={{version}}
- name: Install Cosign
uses: sigstore/cosign-installer@main
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Verify base image signature
run: cosign verify --key .keys/distroless.pub gcr.io/distroless/nodejs:$NODE_VERSION
env:
NODE_VERSION: ${{ steps.node_version.outputs.version }}
# https://github.com/GoogleContainerTools/distroless/issues/975
# - name: Verify base image provenance
# run: cosign verify-attestation --key .keys/distroless.pub gcr.io/distroless/nodejs:$NODE_VERSION
# env:
# NODE_VERSION: ${{ steps.node_version.outputs.version }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: node_version=${{ steps.node_version.outputs.version }}
# Visit the following repos for more options:
# https://github.com/sigstore/cosign-installer
# https://github.com/sigstore/cosign
- name: Sign the image with GitHub OIDC **EXPERIMENTAL**
run: cosign sign --force=$FORCE --oidc-issuer https://token.actions.githubusercontent.com ${TAGS}
env:
COSIGN_EXPERIMENTAL: 1
FORCE: ${{ github.event.repository.private }}
TAGS: ${{ steps.meta.outputs.tags }}