-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (105 loc) · 3.37 KB
/
test-build.yaml
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
name: Test and build
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: 'Tag for docker image'
required: true
env:
IMAGE_TAG: ${{ inputs.tag || github.run_id }}
GITHUB_REGISTRY: ghcr.io
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.22'
- name: Updating docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Start OpenFGA
run: docker-compose -f hosting/docker-compose.yaml up --wait
- name: Run tests
working-directory: ./operator
run: make test
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-22.04
needs:
- test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
working-directory: ./operator
run: make docker-build docker-push IMG=${{ env.GITHUB_REGISTRY }}/${{ github.repository }}:${{ env.IMAGE_TAG }}
scan-image:
permissions:
actions: read
contents: read
packages: read
runs-on: ubuntu-22.04
needs:
- build
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker pull
run: |
docker pull ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}:${{ env.IMAGE_TAG }}
- name: Run Snyk to check Docker images for vulnerabilities
id: snyk_scan
uses: snyk/actions/docker@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: ${{ env.GITHUB_REGISTRY }}/${{ github.repository }}:${{ env.IMAGE_TAG }}
args: --file=./operator/Dockerfile --severity-threshold=high --sarif-file-output=snyk.sarif
# # Doesn't work since can't enable in free private repo
# - name: Upload Snyk report as sarif
# uses: github/codeql-action/upload-sarif@v3
# with:
# sarif_file: snyk.sarif
scan-repo:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: ./operator --severity-threshold=high --sarif-file-output=snyk.sarif
# # Doesn't work since can't enable in free private repo
# - name: Upload result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: snyk.sarif