Skip to content

Merge pull request #4454 from sanger/fix-old-message-templates #620

Merge pull request #4454 from sanger/fix-old-message-templates

Merge pull request #4454 from sanger/fix-old-message-templates #620

name: Release image for local development environment
on:
push:
branches:
- master
- develop
env:
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }}
jobs:
build:
name: Automated release fo Docker image
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: 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: 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 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 }}