-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 2.34 KB
/
deploy-ghcr.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
69
name: Build and Push Docker Images
on:
workflow_call:
inputs:
packages_deployment:
description: packages to build and deploy
required: true
type: string
environment:
description: environment to deploy (beta or prod)
required: true
type: string
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
strategy:
matrix:
packages: ${{ fromJson(inputs.packages_deployment) }}
outputs:
DOCKERFILE_EXISTS: ${{ steps.check-dockerfile.outputs.DOCKERFILE_EXISTS }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check if Dockerfile exists
id: check-dockerfile
run: |
if [ ! -f apps/${{ matrix.packages.name }}/Dockerfile ]; then
echo "Dockerfile does not exist"
echo "DOCKERFILE_EXISTS=false" >> $GITHUB_OUTPUT
else
echo "Dockerfile exists"
echo "DOCKERFILE_EXISTS=true" >> $GITHUB_OUTPUT
fi
- name: Set frontend env
if: ${{ contains(fromJson('["web"]'), matrix.packages.name) && steps.check-dockerfile.outputs.DOCKERFILE_EXISTS == 'true' }}
run: |
echo "Setting env for frontend";
echo "NEXT_PUBLIC_SUPABASE_URL=\"${{ vars.SUPABASE_URL }}\"" >> apps/${{ matrix.packages.name }}/.env
echo "NEXT_PUBLIC_SUPABASE_ANON_KEY=\"${{ vars.SUPABASE_ANON_KEY }}\"" >> apps/${{ matrix.packages.name }}/.env
echo "NEXT_PUBLIC_APP_ENV=\"${{ inputs.environment }}\"" >> apps/${{ matrix.packages.name }}/.env
echo "NEXT_PUBLIC_BACKEND_URL=\"${{ vars.BACKEND_URL }}\"" >> apps/${{ matrix.packages.name }}/.env
- name: Login ghcr.io
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: true
- name: Build and Push to ghcr
if: steps.check-dockerfile.outputs.DOCKERFILE_EXISTS == 'true'
uses: docker/build-push-action@v3.2.0
with:
context: .
file: apps/${{ matrix.packages.name }}/Dockerfile
build-args: |
"ENVIRONMENT=${{ inputs.environment }}"
tags: ${{ matrix.packages.imageTag }}
push: true