-
Notifications
You must be signed in to change notification settings - Fork 56
75 lines (65 loc) · 1.87 KB
/
build-image.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
name: Build Image
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build'
required: true
type: string
deployment-env:
description: 'Deployment environment'
type: choice
options:
- staging
- production
workflow_call:
inputs:
tag:
description: 'Tag to build'
required: true
type: string
deployment-env:
description: 'Deployment environment'
type: string
concurrency:
group: ${{ github.workflow }}
permissions:
contents: write
packages: write
jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine registry and app
id: determine
run: |
tag=${{ inputs.tag }}
force_build=""
if [[ "$tag" == console-api/* ]]; then
echo "registry=${{ vars.API_REGISTRY }}" >> $GITHUB_ENV
echo "app=api" >> $GITHUB_ENV
elif [[ "$tag" == console-web/* ]]; then
echo "registry=${{ vars.WEB_REGISTRY }}" >> $GITHUB_ENV
echo "app=deploy-web" >> $GITHUB_ENV
echo "force_build=-f" >> $GITHUB_ENV
else
echo "Error: Unknown tag format"
exit 1
fi
tag="${tag#*/}"
tag="${tag#v}"
echo "tag=$tag" >> $GITHUB_ENV
- name: Build Docker image
env:
DEPLOYMENT_ENV: ${{ inputs.deployment-env }}
run: |
./packages/docker/script/build.sh -r ${{ env.registry }} -t ${{ env.tag }} -a ${{ env.app }} ${{ env.force_build }}