Skip to content

Merge pull request #318 from sanger/depfu/batch_all/2024-04-01 #218

Merge pull request #318 from sanger/depfu/batch_all/2024-04-01

Merge pull request #318 from sanger/depfu/batch_all/2024-04-01 #218

Workflow file for this run

name: Build and publish Docker image
on:
push:
branches:
- develop
- master
tags:
- release-*
- uat-*
- dev-*
env:
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }}
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- run: env
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: /var/lib/docker
key: ${{ runner.os }}-docker-${{ hashFiles('Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-${{ hashFiles('Dockerfile') }}
- name: Build and tag the Docker image
run: docker build . --file Dockerfile --tag docker.pkg.github.com/${IMAGE_NAME}:${GITHUB_REF##*/}
- name: Tag (latest) the Docker image
run: docker tag docker.pkg.github.com/${IMAGE_NAME}:${GITHUB_REF##*/} docker.pkg.github.com/${IMAGE_NAME}:latest
if: github.ref == 'refs/heads/master'
- name: Login to registry
run: docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
- name: Publish image
run: docker push docker.pkg.github.com/${IMAGE_NAME}:${GITHUB_REF##*/}
- name: Publish image (latest)
run: docker push docker.pkg.github.com/${IMAGE_NAME}:latest
if: github.ref == 'refs/heads/master'
- name: Remove old releases
uses: snok/container-retention-policy@v2
with:
image-names: ${{ github.event.repository.name }}/*
cut-off: Ten months ago UTC
timestamp-to-use: updated_at
account-type: org
org-name: sanger
keep-at-least: 5
skip-tags: latest
token: ${{ secrets.REMOVE_OLD_IMAGES }}