forked from aquasecurity/trivy
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (134 loc) · 5.37 KB
/
Copy pathrelease.yaml
File metadata and controls
146 lines (134 loc) · 5.37 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Release
on:
push:
tags:
- "v*"
jobs:
release:
name: Release
uses: ./.github/workflows/reusable-release.yaml
with:
goreleaser_config: goreleaser.yml
goreleaser_options: '--clean --timeout 90m'
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
ECR_ACCESS_KEY_ID: ${{ secrets.ECR_ACCESS_KEY_ID }}
ECR_SECRET_ACCESS_KEY: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
deploy-packages:
name: Deploy rpm/deb packages
needs: release # run this job after 'release' job completes
runs-on: ubuntu-2404-2core
steps:
# GITHUB_TOKEN is scoped to the current repository and cannot trigger
# workflows in other repos — generate a GitHub App installation token instead.
- name: Generate token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.ACTIONS_MULTI_WRITE_GH_APP_CLIENT_ID }}
private-key: ${{ secrets.TRIVY_WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: trivy-repo
permission-actions: write
- name: Trigger deploy-packages workflow in trivy-repo
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run deploy-packages.yml \
--repo "$GITHUB_REPOSITORY_OWNER/trivy-repo" \
--ref main \
--field "version=$GITHUB_REF_NAME"
# `update-chart-version` creates a new PR for updating the helm chart
update-chart-version:
needs: release
runs-on: ubuntu-2404-2core
steps:
# GITHUB_TOKEN cannot trigger workflows on PRs it creates, so the chart
# version PR would not run CI — generate a GitHub App installation token instead.
- name: Generate token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.REPO_TRIVY_WRITE_GH_APP_CLIENT_ID }}
private-key: ${{ secrets.REPO_TRIVY_WRITE_GH_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: true # mage helm:updateVersion runs git push
token: ${{ steps.app-token.outputs.token }}
- name: Set up Git user
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Set up Go
uses: ./.github/actions/setup-go
- name: Install Go tools
run: go install tool # GOBIN is added to the PATH by the setup-go action
- name: Create a PR with Trivy version
run: mage helm:updateVersion
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# `trigger-version-update` triggers workflows in the `aqua` repositories to update the Trivy version.
trigger-version-update:
needs: release
runs-on: ubuntu-2404-2core
steps:
# GITHUB_TOKEN is scoped to the current repository and cannot trigger
# workflows in other repos — generate a GitHub App installation token instead.
- name: Generate token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.ACTIONS_MULTI_WRITE_GH_APP_CLIENT_ID }}
private-key: ${{ secrets.TRIVY_WORKFLOW_TRIGGER_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: |
trivy-telemetry
trivy-downloads
trivy-chocolatey
trivy-action
permission-actions: write
- name: Trigger update_version workflow in trivy-telemetry
if: always()
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run update_version.yml \
--repo "$GITHUB_REPOSITORY_OWNER/trivy-telemetry" \
--ref main \
--field "version=$GITHUB_REF_NAME"
- name: Trigger update_version workflow in trivy-downloads
if: always()
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run update_version.yml \
--repo "$GITHUB_REPOSITORY_OWNER/trivy-downloads" \
--ref main \
--field "version=$GITHUB_REF_NAME" \
--field artifact=trivy
- name: Trigger version update and release workflow in trivy-chocolatey
if: always()
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run release.yml \
--repo "$GITHUB_REPOSITORY_OWNER/trivy-chocolatey" \
--ref main \
--field "version=$GITHUB_REF_NAME"
- name: Run version bump in trivy-action
if: always()
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
gh workflow run bump-trivy.yaml \
--repo "$GITHUB_REPOSITORY_OWNER/trivy-action" \
--ref master \
--field "trivy_version=$VERSION"