Skip to content

Merge pull request #60 from sanger/dpl-952-support-traction-v2-api #59

Merge pull request #60 from sanger/dpl-952-support-traction-v2-api

Merge pull request #60 from sanger/dpl-952-support-traction-v2-api #59

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
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: Run tests against the image
run: >-
docker run
--entrypoint ''
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
python -m pytest --no-cov -vx
- name: Set release tag
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: echo "RELEASE_VERSION=$(printf -- '%s%s\n' $(cat .release-version) $([ ${BRANCH_NAME} = "develop" ] && printf -- '-%s-develop' ${GITHUB_RUN_ID} || echo ""))" >> $GITHUB_ENV
- name: Create release
uses: ncipollo/[email protected]
with:
name: ${{ env.RELEASE_VERSION }}
tag: v${{ env.RELEASE_VERSION }}
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_VERSION }}
- name: Push release tag image to registry
run: >-
docker push docker.pkg.github.com/${IMAGE_NAME}:${{ env.RELEASE_VERSION }}
- name: Remove the oldest package
# The delete-package-versions action has become broken and the fix doesn't look imminent.
# Re-enable this later if a fix comes out! https://github.com/actions/delete-package-versions/issues/28
if: false
uses: actions/delete-package-versions@v1
with:
package-name: "${{ github.event.repository.name }}"