-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (73 loc) · 2.55 KB
/
ci-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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: build
on:
push:
branches:
tags:
paths:
- ".github/workflows/ci-build.yml"
- "backend/**"
- "frontend/apps/**"
- ".dockerignore"
- "Dockerfile"
- "!**.md"
- "!frontend/packages/**"
pull_request:
paths:
- ".github/workflows/ci-build.yml"
- "backend/**"
- "frontend/apps/**"
- ".dockerignore"
- "Dockerfile"
- "!**.md"
- "!frontend/packages/**"
jobs:
build-images:
name: Build Docker images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: install .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.x.x
- name: restore .NET tools
run: dotnet tool restore
- name: build docker image without pushing (only outside master)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
version="$(dotnet gitversion /showvariable SemVer)"
docker buildx build --build-arg VERSION=${version}
- name: build and deploy master image to ghcr.io
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
version="$(dotnet gitversion /showvariable SemVer)"
echo "GITHUB_SHA=${GITHUB_SHA}"
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg VERSION=${version} \
-t ghcr.io/yurii-hunter/botan:${version} .
- name: deploy tagged (latest) to ghcr.io
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
version="$(dotnet gitversion /showvariable SemVer)"
echo "VERSION=${version}"
echo "GITHUB_SHA=${GITHUB_SHA}"
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg VERSION=${version} \
-t ghcr.io/yurii-hunter/botan:${version} -t ghcr.io/yurii-hunter/botan:latest .