-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (100 loc) · 3.57 KB
/
automated_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
name: Automated build, test, release and push
on:
push:
branches:
- develop
- master
env:
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }}
jobs:
build_test_release_push:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: unified_warehouse_test
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: MyS3cr3tPassw0rd
steps:
- uses: actions/checkout@v2
- uses: nelonoel/[email protected]
- name: Build and tag the image for testing and release
run: >-
docker build .
--file Dockerfile
--tag docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.2
mongodb-replica-set: heron_rs
- name: Create SQL Server testing database
run: >-
docker run
--network host
--env EVE_SETTINGS=test.py
--entrypoint ''
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
python setup_sqlserver_test_db.py
- name: Setup the test MLWH and Events databases
run: >-
docker run
--network host
--env EVE_SETTINGS=test.py
--entrypoint ''
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
python setup_test_db.py
- name: Run tests against the image
run: >-
docker run
--network host
--env EVE_SETTINGS=test.py
--entrypoint ''
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
python -m pytest --no-cov -vx
- name: Set release name
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "RELEASE_NAME=$(printf -- '%s%s\n' $(cat .release-version) $([ ${BRANCH_NAME} = "develop" ] && printf -- '-%s-develop' ${GITHUB_RUN_ID} || echo ""))" >> $GITHUB_ENV
- name: Set release tag
run: echo "RELEASE_TAG=v$RELEASE_NAME" >> $GITHUB_ENV
- name: Create release
uses: ncipollo/[email protected]
with:
name: ${{ env.RELEASE_NAME }}
tag: ${{ env.RELEASE_TAG }}
prerelease: ${{ !(github.ref == 'refs/heads/master') }}
commit: ${{ github.sha }}
- name: Login to registry
run: >-
docker login
-u ${{ github.actor }}
-p ${{ secrets.GITHUB_TOKEN }}
docker.pkg.github.com
- name: Tag image with release version
run: >-
docker tag
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_TAG }}
- name: Push release tag image to registry
run: >-
docker push docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_TAG }}
- name: Remove old releases
uses: snok/container-retention-policy@v2
with:
image-names: ${{ github.event.repository.name }}/*
cut-off: Four months ago UTC
timestamp-to-use: updated_at
account-type: org
org-name: sanger
keep-at-least: 5
skip-tags: latest, *[!develop] # This will DELETE any images where the tag contains ANY characters in "develop", excluding '!'
token: ${{ secrets.REMOVE_OLD_IMAGES }}