-
-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (113 loc) · 5.18 KB
/
main.yml
File metadata and controls
122 lines (113 loc) · 5.18 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: BuildEngine v2 Test and Deploy
on:
push:
branches:
- master
- develop
workflow_dispatch:
inputs:
tags:
description: "Tags"
jobs:
check:
uses: "./.github/workflows/setup.yml"
secrets:
AUTH0_SECRET: ${{ secrets.AUTH0_SECRET }}
push-to-ghcr:
runs-on: ubuntu-latest
needs: check
outputs:
DOCKER_TAG: ${{ steps.branch.outputs.DOCKER_TAG }}
ECS_CLUSTER: ${{ steps.branch.outputs.ECS_CLUSTER }}
BUILD_ENGINE_TAG: ${{ steps.push.outputs.BUILD_ENGINE_TAG }}
OTEL_TAG: ${{ steps.push.outputs.OTEL_TAG }}
if: ${{ success() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup node
uses: actions/setup-node@v5
with:
node-version: 24
- name: Determine branch tag
id: branch
run: |
if [[ "${GITHUB_HEAD_REF}" != "" ]]; then BRANCH="${GITHUB_HEAD_REF}"; else BRANCH="${GITHUB_REF_NAME}"; fi
case $BRANCH in develop) DOCKER_TAG="staging" ;; master) DOCKER_TAG="production" ;; *) DOCKER_TAG="${BRANCH//\//-}" ;; esac
case $BRANCH in develop) ECS_CLUSTER="scriptoria-stg";; master) ECS_CLUSTER="scriptoria-prd" ;; *) ECS_CLUSTER="none" ;; esac
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_OUTPUT
echo "ECS_CLUSTER=${ECS_CLUSTER}" >> $GITHUB_OUTPUT
- name: Build Docker images
id: build
run: |
BUILD_ENGINE_BUILD_TAG="build-engine-api:${{ github.run_number }}"
OTEL_BUILD_TAG="build-engine-otel:${{ github.run_number }}"
echo "Building Docker images..."
docker build -t $BUILD_ENGINE_BUILD_TAG .
docker build -t $OTEL_BUILD_TAG -f Dockerfile.otel .
echo "Docker images built successfully."
echo "BUILD_ENGINE_BUILD_TAG=${BUILD_ENGINE_BUILD_TAG}" >> $GITHUB_OUTPUT
echo "OTEL_BUILD_TAG=${OTEL_BUILD_TAG}" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to GHCR
id: push
run: |
BUILD_ENGINE_TAG="ghcr.io/sillsdev/appbuilder-buildengine-api:${{ steps.branch.outputs.DOCKER_TAG }}"
docker tag ${{ steps.build.outputs.BUILD_ENGINE_BUILD_TAG }} ${BUILD_ENGINE_TAG}
docker push ${BUILD_ENGINE_TAG}
echo "BUILD_ENGINE_TAG=${BUILD_ENGINE_TAG}" >> $GITHUB_OUTPUT
OTEL_TAG="ghcr.io/sillsdev/appbuilder-buildengine-otel:${{ steps.branch.outputs.DOCKER_TAG }}"
docker tag ${{ steps.build.outputs.OTEL_BUILD_TAG }} ${OTEL_TAG}
docker push ${OTEL_TAG}
echo "OTEL_TAG=${OTEL_TAG}" >> $GITHUB_OUTPUT
deploy-sil:
needs: push-to-ghcr
uses: "./.github/workflows/deploy.yml"
with:
BUILD_NUMBER: ${{ github.run_number }}
ECS_CLUSTER: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER }} # Restore this when re-enabling
DOCKER_TAG: ${{ needs.push-to-ghcr.outputs.DOCKER_TAG }}
BUILD_ENGINE_TAG: ${{ needs.push-to-ghcr.outputs.BUILD_ENGINE_TAG }}
OTEL_TAG: ${{ needs.push-to-ghcr.outputs.OTEL_TAG }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.SIL__AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SIL__AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.SIL__AWS_DEFAULT_REGION }}
AWS_ECR_ACCOUNT: ${{ secrets.SIL__AWS_ECR_ACCOUNT }}
deploy-fcbh:
needs: push-to-ghcr
if: false # Temporarily disabled - remove this line to re-enable
# if: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER == 'scriptoria-prd' }} # Restore this when re-enabling
uses: "./.github/workflows/deploy.yml"
with:
BUILD_NUMBER: ${{ github.run_number }}
ECS_CLUSTER: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER }}
DOCKER_TAG: ${{ needs.push-to-ghcr.outputs.DOCKER_TAG }}
BUILD_ENGINE_TAG: ${{ needs.push-to-ghcr.outputs.BUILD_ENGINE_TAG }}
OTEL_TAG: ${{ needs.push-to-ghcr.outputs.OTEL_TAG }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.FCBH__AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.FCBH__AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.FCBH__AWS_DEFAULT_REGION }}
AWS_ECR_ACCOUNT: ${{ secrets.FCBH__AWS_ECR_ACCOUNT }}
deploy-lu:
needs: push-to-ghcr
if: false # Temporarily disabled - remove this line to re-enable
# if: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER == 'scriptoria-stg' }} # Restore this when re-enabling
uses: "./.github/workflows/deploy.yml"
with:
BUILD_NUMBER: ${{ github.run_number }}
ECS_CLUSTER: ${{ needs.push-to-ghcr.outputs.ECS_CLUSTER }}
DOCKER_TAG: ${{ needs.push-to-ghcr.outputs.DOCKER_TAG }}
BUILD_ENGINE_TAG: ${{ needs.push-to-ghcr.outputs.BUILD_ENGINE_TAG }}
OTEL_TAG: ${{ needs.push-to-ghcr.outputs.OTEL_TAG }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.LU__AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LU__AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.LU__AWS_DEFAULT_REGION }}
AWS_ECR_ACCOUNT: ${{ secrets.LU__AWS_ECR_ACCOUNT }}