-
Notifications
You must be signed in to change notification settings - Fork 213
137 lines (115 loc) · 5.11 KB
/
build-and-deploy-telemed-intake.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Deploy Intake
env:
CI: false
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment name'
required: true
type: choice
default: 'development'
options:
- development
- testing
incrementVersion:
description: 'Bump Version?'
type: boolean
required: false
versionType:
description: 'Version to bump (major.minor.patch)'
type: choice
default: 'patch'
options:
- patch
- minor
- major
jobs:
deploy:
env:
PACKAGE_LOCATION: packages/telemed-intake/app
ZAMBDAS_LOCATION: packages/telemed-intake/zambdas
SLACK_NOTIFICATION_SERVICE_NAME: ottehr-notifications
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
strategy:
matrix:
node-version: [18.18.0]
steps:
- name: Install SSH Client
uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.OTTEHR_DEMO_PRIVATE_KEY }}
${{ secrets.BUMP_VERSION }}
- name: If environment is production, ensure keys are coming in through input parameters.
if: ${{ github.event.inputs.environment == 'production' && !(github.event.inputs.confirmProduction == 'Yes') }}
run: echo 'Please confirm you want to deploy to production.' && exit 1
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.BUMP_VERSION }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2
with:
version: 9
- name: Check out secrets repo to grab the env file.
uses: actions/checkout@v3
with:
repository: masslight/ottehr-secrets
ssh-key: ${{ secrets.OTTEHR_DEMO_PRIVATE_KEY }}
path: 'secrets'
- name: Move zambda secrets file into the .env directory.
run: mkdir -p ${{ env.ZAMBDAS_LOCATION }}/.env/ && cp -r secrets/telemed-intake-zambdas/* ${{ env.ZAMBDAS_LOCATION }}/.env/
- name: Move app secrets file into the env directory.
run: mkdir -p ${{ env.PACKAGE_LOCATION }}/env/ && cp -r secrets/telemed-intake-app/. ${{ env.PACKAGE_LOCATION }}/env/
- name: Copy env file to local.env to support serverless package command
run: cp ${{ env.ZAMBDAS_LOCATION }}/.env/${{ github.event.inputs.environment }}.json ${{ env.ZAMBDAS_LOCATION }}/.env/local.json
- name: Increase version if input dictates.
if: ${{ github.event.inputs.incrementVersion == 'true' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action Bump Version"
pnpm version ${{ github.event.inputs.versionType }}
- name: Push increased version if input dictates.
if: ${{ github.event.inputs.incrementVersion == 'true' }}
uses: ad-m/github-push-action@master
with:
ssh: true
branch: ${{ github.ref }}
- name: Get Version Number from package.json for build notifications.
id: package-version
uses: martinbeentjes/[email protected]
with:
path: ${{ env.PACKAGE_LOCATION }}
- name: Install dependencies
run: pnpm install
- name: Deploy App
run: cd ${{ env.PACKAGE_LOCATION }} && pnpm run deploy:${{ github.event.inputs.environment }}
- name: Setup zapehr secrets
run: cd ${{ env.ZAMBDAS_LOCATION }} && pnpm setup-zapehr-secrets ${{ github.event.inputs.environment }}
- name: Deploy zambdas
run: cd ${{ env.ZAMBDAS_LOCATION }} && pnpm deploy-zambdas ${{ github.event.inputs.environment }}
- name: Notify Slack
if: always()
uses: edge/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
BRANCH: ${{ github.ref }}
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}
with:
channel: '#ottehr-notifications'
status: ${{ job.status }}
success_text: '${{ env.GITHUB_WORKFLOW }} (Run #${{ env.GITHUB_RUN_NUMBER }}) deploy completed successfully'
failure_text: '${{ env.GITHUB_WORKFLOW }} (Run #${{ env.GITHUB_RUN_NUMBER }}) deploy failed'
cancelled_text: '${{ env.GITHUB_WORKFLOW }} (Run #${{ env.GITHUB_RUN_NUMBER }}) deploy was cancelled'
fields: |
[{ "title": "Service", "value": "${{ env.SLACK_NOTIFICATION_SERVICE_NAME }}", "short": true },
{ "title": "Action URL", "value": "${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}"},
{ "title": "Branch", "value": "${{ env.BRANCH }}", "short": true },
{ "title": "Environment", "value": "${{ env.ENVIRONMENT }}", "short": true },
{ "title": "Version", "value": "${{ env.PACKAGE_VERSION }}", "short": true }]