forked from ckan/ckan-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (47 loc) · 1.67 KB
/
build.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
54
name: Build - Dev and Prod Images
on:
push:
branches:
- master
- dev-sample
- dev-data
jobs:
build-and-push-ghcr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ vars.USERNAME }}
password: ${{ secrets.TOKEN }}
- name: Set dynamic tag
id: set-tag
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
if [[ "${{ github.ref }}" == "refs/heads/dev-sample" ]]; then
echo "::set-output name=tag::ghcr.io/auscope/auscope-ckan-dev:sample-latest"
elif [[ "${{ github.ref }}" == "refs/heads/dev-data" ]]; then
echo "::set-output name=tag::ghcr.io/auscope/auscope-ckan-dev:data-latest"
else
echo "::set-output name=tag::ghcr.io/auscope/auscope-ckan-dev:latest"
fi
- name: Build and Push Docker image to GHCR
uses: docker/build-push-action@v2
with:
context: ./ckan
file: ./ckan/Dockerfile # Consider using a separate Dockerfile for dev if needed
tags: ${{ steps.set-tag.outputs.tag }}
push: true
build-args: |
BRANCH_NAME=${{ env.BRANCH_NAME }}
COMMIT_SHA=${{ env.COMMIT_SHA }}
labels: |
branch=${{ env.BRANCH_NAME }}
commit_sha=${{ env.COMMIT_SHA }}