-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (66 loc) · 2.52 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
name: Release
on:
push:
tags: [ '**' ]
workflow_dispatch:
concurrency: release-${{ github.ref }}
env:
IMAGE_NAME: mgmt-api
WH_COMMONS_CR: us.icr.io/wh-common-rns/hri
jobs:
docker-build:
name: Docker Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine Image Name & Tag
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo IMAGE_ID=$IMAGE_ID:$VERSION
echo "IMAGE_ID=$IMAGE_ID:$VERSION" >> $GITHUB_ENV
- name: Build image
run: docker build . --file docker/Dockerfile --tag $IMAGE_ID --label "runnumber=${GITHUB_RUN_ID}"
- name: Dockle Linter
uses: erzz/[email protected]
with:
image: "${{ env.IMAGE_ID }}"
report-format: sarif
exit-code: 1
failure-threshold: 'WARN'
- name: Vulnerability Scan
uses: aquasecurity/[email protected]
with:
image-ref: "${{ env.IMAGE_ID }}"
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH,MEDIUM'
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: docker push $IMAGE_ID
- name: Push image to WH Commons CR
env:
CLOUD_API_KEY: ${{ secrets.CLOUD_API_KEY }}
run: |
curl -sL https://ibm.biz/idt-installer | bash
ibmcloud login --apikey $CLOUD_API_KEY -r us-south
ibmcloud cr login
docker tag $IMAGE_ID $WH_COMMONS_CR/$IMAGE_NAME:$VERSION
docker push $WH_COMMONS_CR/$IMAGE_NAME:$VERSION
- name: Post Slack Update
if: ${{ failure() }}
id: slack
uses: slackapi/[email protected]
with:
payload: "{\"Repo\":\"${{ github.repository }}\",\"Workflow\":\"${{ github.workflow }}\",\"Branch\":\"${{ env.BRANCH_NAME }}\",\"Link\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}