-
Notifications
You must be signed in to change notification settings - Fork 22
127 lines (109 loc) · 2.94 KB
/
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
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
---
name: Release
on:
push:
branches:
- master
paths-ignore:
- '**.md'
- 'LICENSE'
- '.github/dependabot.yml'
schedule:
# every Saturday
- cron: '0 0 * * 6'
workflow_dispatch:
env:
DOCKER_IMAGE_NAME: gofrolist/molecule
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Docker meta
id: meta
uses: docker/metadata-action@v3.5.0
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}
type=ref,event=branch
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1.6.0
- name: Build Docker image
uses: docker/build-push-action@v2.7.0
with:
context: .
load: true
tags: ${{ env.DOCKER_IMAGE_NAME }}:test
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/test.tar
- name: Upload artifact
uses: actions/upload-artifact@v2.2.4
with:
name: testimage
path: /tmp/test.tar
molecule:
needs:
- build
runs-on: ubuntu-20.04
steps:
- name: Download artifact
uses: actions/download-artifact@v2.0.10
with:
name: testimage
path: /tmp
- name: Load image
run: |
docker load --input /tmp/test.tar
docker image ls -a
- name: Test run Molecule
run: |
docker run --rm ${{ env.DOCKER_IMAGE_NAME }}:test molecule --version
snyk:
needs:
- build
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Download artifact
uses: actions/download-artifact@v2.0.10
with:
name: testimage
path: /tmp
- name: Load image
run: |
docker load --input /tmp/test.tar
docker image ls -a
- name: Run Snyk to check Docker image for vulnerabilities
continue-on-error: true
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: ${{ env.DOCKER_IMAGE_NAME }}:test
sarif: true
args: --file=Dockerfile
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: snyk.sarif
release:
needs:
- build
- molecule
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Setup Node.js
uses: actions/setup-node@v2.4.1
with:
node-version: '14'
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: npx semantic-release -p @semantic-release/commit-analyzer -p @semantic-release/release-notes-generator -p @semantic-release/github