Skip to content

Commit 11861cb

Browse files
committed
Merge branch 'master' of github.com:OriKerer/cpp-dev-container
2 parents 1ea2b80 + e7fe097 commit 11861cb

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/docker-publish.yml

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

0 commit comments

Comments
 (0)