Skip to content

Commit 29bfd28

Browse files
committed
add OIDC token permissions and cosign steps for Docker image signing
1 parent 9097d83 commit 29bfd28

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
packages: write # Permitir publicar pacotes no GitHub Packages
2323
pull-requests: write # Permitir criar e atualizar pull requests
2424
security-events: write # Enviar eventos de segurança para o Github Security
25+
id-token: write # Permitir emitir tokens OIDC para autenticação com provedores externos
2526

2627
steps:
2728
- name: Checkout repository
@@ -101,7 +102,7 @@ jobs:
101102

102103
- name: Extract Docker metadata
103104
id: meta
104-
if: ${{ github.event_name != 'pull_request' }}
105+
if: github.event_name != 'pull_request'
105106
uses: docker/[email protected]
106107
with:
107108
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
@@ -114,7 +115,7 @@ jobs:
114115
115116
- name: Build final
116117
id: build-final
117-
if: ${{ github.event_name != 'pull_request' }}
118+
if: github.event_name != 'pull_request'
118119
uses: docker/[email protected]
119120
with:
120121
context: ./src/ci/nestjs-project
@@ -128,3 +129,17 @@ jobs:
128129
sbom: true
129130
secrets: |
130131
github_token=${{ secrets.MY_GITHUB_TOKEN }}
132+
133+
- name: Install cosign
134+
if: github.event_name != 'pull_request'
135+
uses: sigstore/[email protected]
136+
with:
137+
cosign-release: 'v2.2.4'
138+
139+
- name: Sign the published Docker image
140+
if: github.event_name != 'pull_request'
141+
env:
142+
TAGS: ${{ steps.meta.outputs.tags }} docker metadata tag1,tag2,tag3
143+
DIGEST: ${{ steps.build-final.outputs.digest }}
144+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
145+

0 commit comments

Comments
 (0)