-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (93 loc) · 3.03 KB
/
release-to-ghcr.yaml
File metadata and controls
109 lines (93 loc) · 3.03 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
---
name: Release to GHCR
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: write # Needed to create new releases
packages: write # Needed to push to GHCR
id-token: write # Needed to create an ephemeral cross-repo token
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: prod
# Expose semantic-release outputs so downstream jobs can gate on and read the version
outputs:
new-release-published: ${{ steps.release.outputs.new_release_published }}
new-release-version: ${{ steps.release.outputs.new_release_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: npm ci
- name: Release
id: release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Report skipped release
if: steps.release.outputs.new_release_published != 'true'
run: echo "No releasable commits found — skipping Docker build"
trivy-scan:
name: Security - Trivy Scan
needs: release
if: ${{ needs.release.outputs.new-release-published == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: npm ci
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
severity: 'CRITICAL,HIGH'
exit-code: '1'
ignore-unfixed: true
scanners: 'vuln'
build-and-push:
name: Build and push image to GHCR
needs: [release, trivy-scan]
if: ${{ needs.release.outputs.new-release-published == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/bitgo/advanced-wallets:${{ needs.release.outputs.new-release-version }}
ghcr.io/bitgo/advanced-wallets:latest
build-args: |
BUILD_VERSION=${{ needs.release.outputs.new-release-version }}
BUILD_DATE=${{ github.event.repository.updated_at }}
VCS_REF=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max