forked from openservicemesh/osm
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (85 loc) · 2.75 KB
/
pre-release.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Pre-release
on:
push:
tags:
- "pre-rel-v*"
- "v0.0.0-nightly*"
env:
CTR_REGISTRY: ${{ github.repository_owner }}
jobs:
version:
name: Set Version from git ref
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- id: version
run: echo "::set-output name=version::$(sed 's#^refs/tags/.*\(v[[:digit:]].*\)#\1#' <<< '${{ github.ref }}')"
images:
name: Docker Images
runs-on: ubuntu-latest
needs: version
env:
DOCKER_USER: ${{ secrets.RELEASE_DOCKER_USER }}
DOCKER_PASS: ${{ secrets.RELEASE_DOCKER_PASS }}
VERSION: ${{ needs.version.outputs.version }}
BUILD_DATE: '$$(date +%Y-%m-%d-%H:%M)'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore Module Cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod2-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod2-
- name: Restore Build Cache
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-gobuild-${{ hashFiles('**/*.go') }}
- name: Setup Go 1.16
uses: actions/setup-go@v1
with:
go-version: 1.16
- name: Docker Login
run: docker login --username "$DOCKER_USER" --password-stdin <<< "$DOCKER_PASS"
- name: Push images with version tag
env:
CTR_TAG: ${{ needs.version.outputs.version }}
run: make docker-push VERIFY_TAGS=true
- name: Push images with latest tag
# Only for non-pre-releases
if: ${{ !(contains(env.VERSION, '-alpha.') || contains(env.VERSION, '-beta.') || contains(env.VERSION, '-rc.') || contains(env.VERSION, '-nightly.')) }}
env:
CTR_TAG: latest
run: make docker-push
- name: Upload image digest
uses: actions/upload-artifact@v2
with:
name: osm_image_digests
path: /tmp/osm_image_digest_*
imagescan:
name: Scan images for security vulnerabilities
runs-on: ubuntu-latest
needs: images
env:
CTR_TAG: ${{ needs.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Restore Module Cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod2-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod2-
- name: Restore Build Cache
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-gobuild-${{ hashFiles('**/*.go') }}
- name: Scan docker images for vulnerabilities
run: make trivy-scan-images