-
Notifications
You must be signed in to change notification settings - Fork 22
149 lines (128 loc) · 3.54 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
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-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Docker meta
id: meta
uses: docker/metadata-action@v5.4.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@v3.0.0
- name: Build Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .
file: Dockerfile.buster
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@v4.0.0
with:
name: testimage
path: /tmp/test.tar
molecule:
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4.1.0
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-docker:
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Download artifact
uses: actions/download-artifact@v4.1.0
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@v3
# with:
# sarif_file: snyk.sarif
snyk-python:
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Run Snyk to check for Python vulnerabilities
continue-on-error: true
uses: snyk/actions/python-3.9@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --sarif-file-output=snyk-python.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk-python.sarif
release:
needs:
- build
- molecule
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Setup Node.js
uses: actions/setup-node@v4.0.1
with:
node-version: '18'
- 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