-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) · 1.72 KB
/
docker-publish.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
55
name: Docker build and Publish Image CI
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- v*.*.*
jobs:
build:
runs-on: ubuntu-latest
env:
NAME: teogw
ORG: teonet-go
USER: ${{ secrets.USER }}
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
PACKAGES_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Set name, branch and tag to environment
env:
SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }}
SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }}
SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }}
run: |
echo $SOURCE_NAME
echo $SOURCE_BRANCH
echo $SOURCE_TAG
- name: Build the Docker image
env:
VERSION: ${{ steps.branch_name.outputs.SOURCE_TAG }}
run: docker build --build-arg github_user="$USER" --build-arg github_personal_token="$PERSONAL_TOKEN" --build-arg version="$VERSION" -t $NAME -f ./.github/Dockerfile .
- name: Publish Docker image to Github Packages
env:
VERSION: ${{ steps.branch_name.outputs.SOURCE_TAG }}
run: |
docker login ghcr.io -u $USER -p $PACKAGES_TOKEN
echo ""
docker tag $NAME ghcr.io/$ORG/$NAME:${VERSION:1}
docker push ghcr.io/$ORG/$NAME:${VERSION:1}
echo ""
docker tag $NAME ghcr.io/$ORG/$NAME:latest
docker push ghcr.io/$ORG/$NAME:latest