-
-
Notifications
You must be signed in to change notification settings - Fork 210
123 lines (118 loc) · 3.75 KB
/
Copy pathrelease.yaml
File metadata and controls
123 lines (118 loc) · 3.75 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
on:
workflow_dispatch:
inputs:
logLevel:
description: "Log level"
required: true
default: "warning"
type: choice
options:
- info
- warning
- debug
tags:
description: "Tags"
required: false
type: boolean
release:
types: [created]
env:
DOCKER_IMAGE: quay.io/authorizer/authorizer
# Quay exposes no lifetime pull counter (only a trailing 92-day window), so
# the same image also goes to Docker Hub, which does.
DOCKERHUB_IMAGE: docker.io/lakhansamani/authorizer
BUILDKIT_INLINE_CACHE: 1
jobs:
test:
name: Go tests (SQLite)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Run tests
run: make test
smoke:
name: Release smoke (GraphQL + REST + gRPC + MCP)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
# Black-box end-to-end pass over every public API surface against the
# freshly built binary (see internal/e2e/smoke_test.go).
- name: Run smoke tests
run: make smoke
build:
name: Build and push Docker image
runs-on: ubuntu-latest
needs: [test, smoke]
steps:
- uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
platforms: linux/amd64,linux/arm64
- name: Log in to Quay
uses: docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
env:
SOURCE_URL: https://github.com/${{ github.repository }}
run: |
VERSION=$(basename ${GITHUB_REF})
TAG_ARGS=(-t "${DOCKER_IMAGE}:${VERSION}" -t "${DOCKERHUB_IMAGE}:${VERSION}")
# Only a final release moves :latest. Match strict semver with no
# pre-release suffix (vX.Y.Z / X.Y.Z) so rc/beta/alpha/pre never win.
if [[ "$VERSION" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
TAG_ARGS+=(-t "${DOCKER_IMAGE}:latest" -t "${DOCKERHUB_IMAGE}:latest")
fi
docker buildx build \
--platform linux/amd64,linux/arm64 \
--push \
--provenance=true \
--sbom=true \
--build-arg VERSION="${VERSION}" \
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--build-arg VCS_REF="${GITHUB_SHA}" \
--build-arg SOURCE_URL="${SOURCE_URL}" \
--cache-from type=registry,ref=${DOCKER_IMAGE}:buildcache \
--cache-to type=registry,ref=${DOCKER_IMAGE}:buildcache,mode=max \
"${TAG_ARGS[@]}" \
.
trivy-scan:
name: Vulnerability scan (Trivy)
runs-on: ubuntu-latest
needs: [test, build]
permissions:
contents: read
security-events: write
steps:
- name: Run Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}
format: "sarif"
output: "trivy-results.sarif"
severity: "CRITICAL,HIGH"
- name: Upload Trivy results
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: "trivy-results.sarif"