forked from emrojo/samples_extraction
-
Notifications
You must be signed in to change notification settings - Fork 5
53 lines (47 loc) · 1.72 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 }}