-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 1.67 KB
/
build-web.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Build Web Image
on:
workflow_dispatch:
push:
branches:
- fix/fix-runtime-env
tags:
- 'v*'
env:
IMAGE_NAME: ${{ github.repository }}-web
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Gather tags name
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
SHA: ${{ github.sha }}
REF: ${{ github.ref }}
id: tags
run: |
RESULT="$IMAGE_NAME:latest,$IMAGE_NAME:$SHA"
case "$REF" in
refs/tags/v*)
RESULT="${RESULT},$IMAGE_NAME:${REF#refs/tags/v}"
;;
esac
echo "tags = $RESULT"
echo "tags=$RESULT" >> "$GITHUB_OUTPUT"
- name: Build Docker image with multiple tags
run: |
tags="${{ steps.tags.outputs.tags }}"
for tag in $(echo $tags | tr ',' '\n'); do
docker build . -t ghcr.io/$tag -f ./apps/web/Dockerfile \
--build-arg NEXT_PUBLIC_API_SERVER_URL=${{ secrets.NEXT_PUBLIC_API_SERVER_URL }}
done
- name: Push Docker image to GitHub Container Registry
run: |
tags="${{ steps.tags.outputs.tags }}"
for tag in $(echo $tags | tr ',' '\n'); do
docker push ghcr.io/$tag
done