-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (60 loc) · 1.99 KB
/
package.yml
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
name: Release
on:
push:
tags:
- v**
env:
REGISTRY: ghcr.io/${{ github.repository_owner }}/trivy-extractor
API_IMAGE_NAME: trivy-extractor
Version: ${{ github.ref_name }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.ref_name }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Extract metadata (tags, labels) for Docker
id: meta-api
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
with:
images: ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with:
push: true
file: Dockerfile
tags: ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:${{ env.Version}}
labels: ${{ steps.meta-api.outputs.labels }}
outputs:
tags: ${{ steps.meta-api.outputs.tags }}
sign:
needs: build-and-push-image
runs-on: ubuntu-latest
permissions:
packages: write
id-token: write
steps:
- name: Log in to the Container registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.ref_name }}
- uses: sigstore/cosign-installer@main
- run: cosign sign -y -r ${TAGS}
env:
TAGS: ${{needs.build-and-push-image.outputs.tags}}