Skip to content

Commit f91e943

Browse files
committed
ci: update docker action
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent ad82ed2 commit f91e943

File tree

1 file changed

+75
-24
lines changed

1 file changed

+75
-24
lines changed

.github/workflows/docker.yml

Lines changed: 75 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,90 @@
1-
name: 'Docker Publish'
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.
27

38
on:
49
push:
5-
tags:
6-
- '*'
10+
tags: [ '*' ]
11+
12+
env:
13+
# Use docker.io for Docker Hub if empty
14+
REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
IMAGE_NAME: ${{ github.repository }}
17+
718

819
jobs:
9-
push_to_registry:
10-
name: Push Docker image to GitHub Packages
20+
build:
21+
1122
runs-on: ubuntu-latest
1223
permissions:
13-
packages: write
1424
contents: read
25+
packages: write
26+
# This is used to complete the identity challenge
27+
# with sigstore/fulcio when running outside of PRs.
28+
id-token: write
29+
1530
steps:
16-
- name: Check out the repo
17-
uses: actions/checkout@v2
18-
- name: Determine the source tag
19-
id: get_source_tag
20-
run: |
21-
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
22-
- name: Log in to GitHub Docker Registry
23-
uses: docker/login-action@v1
31+
- name: Checkout repository
32+
uses: actions/checkout@v3
33+
34+
# Install the cosign tool except on PR
35+
# https://github.com/sigstore/cosign-installer
36+
- name: Install cosign
37+
if: github.event_name != 'pull_request'
38+
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
2439
with:
25-
registry: docker.pkg.github.com
26-
username: ${{ github.actor }}
27-
password: ${{ secrets.GITHUB_TOKEN }}
28-
- name: Log in to GitHub Container Registry
29-
uses: docker/login-action@v1
40+
cosign-release: 'v1.13.1'
41+
42+
43+
# Workaround: https://github.com/docker/build-push-action/issues/461
44+
- name: Setup Docker buildx
45+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
46+
47+
# Login against a Docker registry except on PR
48+
# https://github.com/docker/login-action
49+
- name: Log into registry ${{ env.REGISTRY }}
50+
if: github.event_name != 'pull_request'
51+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
3052
with:
31-
registry: ghcr.io
53+
registry: ${{ env.REGISTRY }}
3254
username: ${{ github.actor }}
3355
password: ${{ secrets.GITHUB_TOKEN }}
34-
- name: Build container image
35-
uses: docker/build-push-action@v2
56+
57+
# Extract metadata (tags, labels) for Docker
58+
# https://github.com/docker/metadata-action
59+
- name: Extract Docker metadata
60+
id: meta
61+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
3662
with:
63+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
64+
65+
# Build and push Docker image with Buildx (don't push on PR)
66+
# https://github.com/docker/build-push-action
67+
- name: Build and push Docker image
68+
id: build-and-push
69+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
70+
with:
71+
context: .
3772
push: true
38-
tags: |
39-
ghcr.io/nextcloud/univention-app:${{ steps.get_source_tag.outputs.SOURCE_TAG }}
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
78+
79+
# Sign the resulting Docker image digest except on PRs.
80+
# This will only write to the public Rekor transparency log when the Docker
81+
# repository is public to avoid leaking data. If you would like to publish
82+
# transparency data even for private images, pass --force to cosign below.
83+
# https://github.com/sigstore/cosign
84+
- name: Sign the published Docker image
85+
if: ${{ github.event_name != 'pull_request' }}
86+
env:
87+
COSIGN_EXPERIMENTAL: "true"
88+
# This step uses the identity token to provision an ephemeral certificate
89+
# against the sigstore community Fulcio instance.
90+
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}

0 commit comments

Comments
 (0)