-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (39 loc) · 1.65 KB
/
build.yml
File metadata and controls
47 lines (39 loc) · 1.65 KB
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
# NOTES:
# 1. Create PAT with `read:packages` and `write:packages` see https://docs.github.com/en/free-pro-team@latest/packages/guides/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry
# 2. Create CR_PAT variable under Settings / Secrets
name: BUILD
on:
push:
# Publish `v1.2.3` tags as releases.
tags:
- v*
env:
FETCHER_IMAGE_VERSION: ""
BASE_IMAGE_VERSION: ""
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run build
run: |
IMAGE_NAME=ghcr.io/$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]' )
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
docker build . \
--build-arg FETCHER_IMAGE_VERSION=${FETCHER_IMAGE_VERSION} \
--build-arg BASE_IMAGE_VERSION=${BASE_IMAGE_VERSION} \
--file Dockerfile --tag $IMAGE_NAME:$VERSION
- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to GitHub Container Registry
run: |
IMAGE_NAME=ghcr.io/$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]' )
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker push $IMAGE_NAME:$VERSION
# Push latest as well for caching purposes
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest
docker push $IMAGE_NAME:latest