forked from getporter/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (70 loc) · 2.12 KB
/
build.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
name: build
on:
workflow_dispatch: {}
push:
branches:
- "main"
tags:
- 'v*'
pull_request: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Set up Mage
run: go run mage.go EnsureMage
- name: VetLint
run: mage -v vet lint
- name: Test
run: mage -v Test
env:
PORTER_TEST_WAIT_TIMEOUT: 2m
- name: Report Unit Test Coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage-unit.out
flags: unittests
- name: Report Integration Test Coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage-integration.out
flags: integration-tests
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.MANAGER_IMAGE }}
format: sarif
output: trivy-results.sarif
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-results.sarif
- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Publish
if: ${{ github.event_name != 'pull_request' }}
run: |
if [[ "${GITHUB_REPOSITORY}" != "getporter/operator" ]]; then
# If publishing from fork PORTER_OPERATOR_REGISTRY
# must be set as a CI env variable and GHCR_USER and GHCR_TOKEN set
# as secrets with permissions to publish images
export PORTER_ENV=fork
export PORTER_OPERATOR_REGISTRY=${{ vars.PORTER_OPERATOR_REGISTRY }}
fi
mage -v Publish
env:
PORTER_ENV: production