forked from hotosm/tasking-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (108 loc) · 3.46 KB
/
build_and_deploy.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
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
name: Build and Deploy
on:
# Push includes PR merge
push:
branches:
- main
- staging
- develop
- ci-gh-workflows
paths:
# Workflow is triggered only if src changes
- backend/**
- frontend/**
# Allow manual trigger
workflow_dispatch:
jobs:
frontend-test:
uses: naxa-developers/tasking-manager/.github/workflows/frontend-test.yml@ci-gh-workflows
secrets: inherit
with:
node-version: 16.x
context: ./frontend
cache-key-file: ./frontend/yarn.lock
package-manager: yarn
# TODO: Verify this with frontend team
test_frontend_command: |
CI=true yarn test -w 1
# test_frontend_build: false
# build_test_frontend_command: |
# CI=true GENERATE_SOURCEMAP=false yarn build
frontend-build:
uses: naxa-developers/tasking-manager/.github/workflows/frontend-build.yml@ci-gh-workflows
secrets: inherit
needs:
- frontend-test
with:
node-version: 16.x
context: ./frontend
cache-key-file: ./frontend/yarn.lock
package-manager: yarn
build-dist-folder-path: ./frontend/build
frontend-deploy:
runs-on: ubuntu-latest
needs:
- frontend-test
- frontend-build
name: Deploy Frontend Static Files
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ needs.frontend-build.outputs.artifact-name }}
path: ./build
#TODO: Handle Auth and upload to respective s3 bucket & do a cloudfront invalidation
- name: Debug check files
run: |
ls -alh
ls -alh build
backend-build:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
with:
context: .
build_target: prod
image_name: ghcr.io/${{ github.repository }}/backend
dockerfile: Dockerfile
scan_image: false
secrets: inherit
backend-test:
needs:
- backend-build
uses: naxa-developers/tasking-manager/.github/workflows/test_compose.yml@ci-gh-workflows
with:
image_name: ghcr.io/${{ github.repository }}/backend
pre_command: |
docker compose --file docker-compose.yml up -d
sleep 15
docker compose --file docker-compose.yml logs tm-backend
compose_service: tm-backend
build_target: prod
# TODO: Compose command to be updated once dev have test setup running. For now just a simple curl command.
compose_command: curl -i http://localhost:5000/api/v2/
tag_override: ci-${{ github.ref_name }}
# coverage: true
example_env_file_path: example.env
env_file_path: tasking-manager.env
secrets: inherit
backup-database:
runs-on: ubuntu-latest
needs:
- backend-test
name: Backup Database before deployment
steps:
- name: Create Snapshot
run:
echo " TODO Database backup Steps; See CircleCI"
# See https://app.circleci.com/pipelines/github/hotosm/tasking-manager/11487/workflows/e98ba643-5812-4b2a-a09f-cc499285b3cc/jobs/23599
#TODO: Check circleci for references
backend_deploy_to_vm:
name: Deploy Backend to VM
needs:
- backup-database
uses: naxa-developers/tasking-manager/.github/workflows/remote_deploy_compose.yml@ci-gh-workflows
with:
docker_compose_file: docker-compose.yml
environment: ${{ github.ref_name }}
example_env_file_path: example.env
env_file_path: tasking-manager.env
secrets: inherit