-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (42 loc) · 1.21 KB
/
docker_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
47
48
name: Docker Build
on:
release:
types:
- published
push:
branches:
- dev
- staging
- main
jobs:
docker_publish:
name: Docker Build
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Branch name
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
SANITIZED_BRANCH_NAME=${BRANCH_NAME//\//-}
echo "BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV
- name: Build image with env tag
if: github.ref == 'refs/heads/dev'
|| github.ref == 'refs/heads/staging'
|| github.ref == 'refs/heads/main'
uses: macbre/push-to-ghcr@master
with:
image_name: ${{ github.repository }}
image_tag: ${{ env.BRANCH_NAME }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build image with semver tag
if: startsWith(github.ref, 'refs/tags/')
uses: macbre/push-to-ghcr@master
with:
image_name: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}