-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.42 KB
/
build.yaml
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
name: build
on:
push:
branches:
- master
tags:
- 'v*.*.*'
permissions:
packages: write
jobs:
docker-build-and-publish:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@master
- name: Set env
env:
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
echo "IS_TAG=${IS_TAG}"
if [[ $(echo ${GITHUB_REF#refs/heads/}) == "master" ]]
then
echo "RELEASE_VERSION=latest" >> $GITHUB_ENV
elif [[ $(echo ${GITHUB_REF#refs/heads/}) == "develop" ]]
then
echo "RELEASE_VERSION=latest-develop" >> $GITHUB_ENV
elif [[ ${IS_TAG} == "false" ]]
then
echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
fi
- name: Publish tag to registry
env:
IMAGE: ${{ github.repository }}
GITHUB_USER: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ github.token }}
run: |
image=`echo -n "${IMAGE}" | tr 'A-Z' 'a-z'`
echo "${image}:${RELEASE_VERSION}"
docker build -t ghcr.io/${image}:${RELEASE_VERSION} .
docker login -u "${GITHUB_USER}" -p "${GITHUB_TOKEN}" ghcr.io
docker push ghcr.io/${image}:${RELEASE_VERSION}