This repository was archived by the owner on Nov 6, 2023. It is now read-only.
generated from dwp/dataworks-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 4
71 lines (65 loc) · 2.33 KB
/
main.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: Master
on:
push:
branches:
- master
env:
IMAGE_NAME: dwpdigital/alpine-prometheus
jobs:
get-publish-version:
runs-on: ubuntu-latest
outputs:
publish-version: ${{ steps.get-publish-version.outputs.publish-version }}
steps:
- name: Get publish version
id: get-publish-version
run: |
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
[ -z "$LATEST_VERSION" ] && LATEST_VERSION="0.0.0"
VERSION=$(echo $LATEST_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
echo "::set-output name=publish-version::${VERSION}"
publish-github-release:
runs-on: ubuntu-latest
needs: get-publish-version
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create GitHub Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.get-publish-version.outputs.publish-version }}
release_name: Release ${{ needs.get-publish-version.outputs.publish-version }}
draft: false
prerelease: false
publish-docker:
runs-on: ubuntu-latest
needs: get-publish-version
steps:
- uses: actions/checkout@master
- name: Get release version
id: get_version
run: echo RELEASE_VERSION=$(echo ${GITHUB_REF:10}) >> $GITHUB_ENV
- name: Publish to DockerHub
uses: elgohr/Publish-Docker-Github-Action@191af57e15535d28b83589e3b5f0c31e76aa8733 #v3.0.4 hardcoded for security DW-5986, review regularly
with:
name: ${{ env.IMAGE_NAME }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tags: "latest, ${{ needs.get-publish-version.outputs.publish-version }}"
tag_semver: true
snyk-monitor:
runs-on: ubuntu-latest
needs: publish-docker
steps:
- uses: actions/checkout@v2
- name: Run Snyk monitoring
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
image: ${{ env.IMAGE_NAME }}
args: --file=Dockerfile --org=dwp-dataworks