Merge pull request #942 from sanger/dependabot/pip/flask-cors-4.0.1 #411
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |