-
Notifications
You must be signed in to change notification settings - Fork 5
36 lines (30 loc) · 1.1 KB
/
push-docker-images.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
name: Push Docker image to GH packages
on:
push:
branches:
- 'main'
jobs:
build_docker_images:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag ${{ github.repository }} --label "runnumber=${GITHUB_RUN_ID}"
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
set -x
IMAGE_ID=ghcr.io/${{ github.repository }}
VERSION=$(cat version)
SHA_TAG=sha-${GITHUB_SHA:0:8}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag ${{ github.repository }} $IMAGE_ID:latest
docker tag ${{ github.repository }} $IMAGE_ID:$SHA_TAG
docker tag ${{ github.repository }} $IMAGE_ID:$VERSION
docker push $IMAGE_ID:latest
docker push $IMAGE_ID:$SHA_TAG
docker push $IMAGE_ID:$VERSION
- name: Checkout
uses: actions/checkout@v2