1
1
name : Push ghcr
2
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 18 * * *'
11
- # push:
12
- # branches: [ "main" ]
13
- # # Publish semver tags as releases.
14
- # tags: [ 'v*.*.*' ]
15
- # pull_request:
16
- # branches: [ "main" ]
17
3
on :
4
+ push :
5
+ tags : ["v*.*.*"]
18
6
workflow_dispatch :
19
7
inputs :
20
8
branch :
23
11
default : " main"
24
12
25
13
env :
26
- # Use docker.io for Docker Hub if empty
27
14
REGISTRY : ghcr.io
28
- # github.repository as <account>/<repo>
29
15
IMAGE_NAME : ${{ github.repository }}
30
16
31
17
jobs :
@@ -34,57 +20,41 @@ jobs:
34
20
permissions :
35
21
contents : read
36
22
packages : write
37
- # This is used to complete the identity challenge
38
- # with sigstore/fulcio when running outside of PRs.
39
23
id-token : write
40
24
41
25
steps :
42
26
- name : Checkout repository
43
27
uses : actions/checkout@v4
44
28
with :
45
- ref : ${{ github.event.inputs.branch }}
29
+ ref : ${{ github.ref }}
46
30
submodules : " true"
47
31
48
- # Install the cosign tool except on PR
49
- # https://github.com/sigstore/cosign-installer
50
32
- name : Install cosign
51
33
if : github.event_name != 'pull_request'
52
- uses : sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
34
+
53
35
with :
54
36
cosign-release : " v2.2.4"
55
37
56
- # Set up BuildKit Docker container builder to be able to build
57
- # multi-platform images and export cache
58
- # https://github.com/docker/setup-buildx-action
59
38
- name : Set up Docker Buildx
60
- uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
39
+
61
40
62
- # Login against a Docker registry except on PR
63
- # https://github.com/docker/login-action
64
41
- name : Log into registry ${{ env.REGISTRY }}
65
42
if : github.event_name != 'pull_request'
66
- uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
43
+
67
44
with :
68
45
registry : ${{ env.REGISTRY }}
69
46
username : ${{ github.actor }}
70
47
password : ${{ secrets.GITHUB_TOKEN }}
71
48
72
- # Extract metadata (tags, labels) for Docker
73
- # https://github.com/docker/metadata-action
74
49
- name : Extract Docker metadata
75
50
id : meta
76
- uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
51
+
77
52
with :
78
53
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
79
- tags : |
80
- type=ref,event=branch
81
- type=raw,value=${{ github.event.inputs.branch }}
82
54
83
- # Build and push Docker image with Buildx (don't push on PR)
84
- # https://github.com/docker/build-push-action
85
55
- name : Build and push Docker image
86
56
id : build-and-push
87
- uses : docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
57
+
88
58
with :
89
59
context : .
90
60
push : ${{ github.event_name != 'pull_request' }}
93
63
cache-from : type=gha
94
64
cache-to : type=gha,mode=max
95
65
96
- # Sign the resulting Docker image digest except on PRs.
97
- # This will only write to the public Rekor transparency log when the Docker
98
- # repository is public to avoid leaking data. If you would like to publish
99
- # transparency data even for private images, pass --force to cosign below.
100
- # https://github.com/sigstore/cosign
101
66
- name : Sign the published Docker image
102
67
if : ${{ github.event_name != 'pull_request' }}
103
68
env :
104
- # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
105
69
TAGS : ${{ steps.meta.outputs.tags }}
106
70
DIGEST : ${{ steps.build-and-push.outputs.digest }}
107
- # This step uses the identity token to provision an ephemeral certificate
108
- # against the sigstore community Fulcio instance.
109
71
run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
0 commit comments