This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
Merge pull request #527 from sanger/dependabot/npm_and_yarn/eslint-pl… #344
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: Build, test and release | |
on: | |
push: | |
branches: | |
- develop | |
- master | |
env: | |
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }} | |
jobs: | |
build_test_and_release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: nelonoel/branch-name@v1.0.1 | |
- 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 | |
--network host | |
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME} | |
npm test | |
- name: Set release name | |
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable | |
# On the develop branch this might create RELEASE_NAME=2.4.6-987654321-develop | |
# On the master branch this would then only create RELEASE_NAME=2.4.6 | |
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/release-action@v1.8.8 | |
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 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 }}' |