-
Notifications
You must be signed in to change notification settings - Fork 4
151 lines (147 loc) · 5.33 KB
/
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
name: Deploy to cloud.gov
on:
push:
branches:
- main
workflow_dispatch:
inputs:
version_no:
description: 'Release Version:'
required: true
env:
POETRY_VERSION: "1.7.1"
jobs:
deploy-staging:
name: deploy staging
environment: staging
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Build static assets
shell: bash
run: |
cd app/static
npm install
npm run build
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Add requirement.txt
run: |
poetry export -f requirements.txt --output requirements.txt --without-hashes
echo "Generated requirements.txt:"
cat requirements.txt
- name: deploy DHL
uses: cloud-gov/cg-cli-tools@main
with:
command: cf push --vars-file vars.staging.yml --strategy rolling --no-wait
cf_org: gsa-datagov
cf_space: ${{vars.ENVIRONMENT_NAME}}
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}
# to-do
# - name: smoke test
# uses: cloud-gov/cg-cli-tools@main
# with:
# command: cf run-task harvesting-logic -c "/home/vcap/app/scripts/smoke-test.py" --name smoke-test
# cf_org: gsa-datagov
# cf_space: ${{vars.ENVIRONMENT_NAME}}
# cf_username: ${{secrets.CF_SERVICE_USER}}
# cf_password: ${{secrets.CF_SERVICE_AUTH}}
# - name: monitor task output
# uses: cloud-gov/cg-cli-tools@main
# with:
# command: >
# scripts/monitor-cf-logs.sh harvesting-logic smoke-test
# cf_org: gsa-datagov
# cf_space: ${{vars.ENVIRONMENT_NAME}}
# cf_username: ${{secrets.CF_SERVICE_USER}}
# cf_password: ${{secrets.CF_SERVICE_AUTH}}
- name: Create Issue if it fails 😢
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }}
GITHUB_JOB: ${{ toJson(github)['job'] }}
GITHUB_ATTEMPTS: ${{ github.run_attempt }}
LAST_COMMIT: ${{ github.sha }}
LAST_RUN_BY: ${{ github.actor }}
RUN_ID: ${{ github.run_id }}
REPO: ${{ github.repository }}
with:
filename: .github/deploy_failure.md
update_existing: true
deploy-prod:
name: deploy prod
needs: deploy-staging
environment: prod
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Build static assets
shell: bash
run: |
cd app/static
npm install
npm run build
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Add requirement.txt
run: |
poetry export -f requirements.txt --output requirements.txt --without-hashes
echo "Generated requirements.txt:"
cat requirements.txt
- name: deploy DHL
uses: cloud-gov/cg-cli-tools@main
with:
command: cf push --vars-file vars.prod.yml --strategy rolling --no-wait
cf_org: gsa-datagov
cf_space: ${{vars.ENVIRONMENT_NAME}}
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}
# to-do
# - name: smoke test
# uses: cloud-gov/cg-cli-tools@main
# with:
# command: cf run-task harvesting-logic -c "/home/vcap/app/scripts/smoke-test.py" --name smoke-test
# cf_org: gsa-datagov
# cf_space: ${{vars.ENVIRONMENT_NAME}}
# cf_username: ${{secrets.CF_SERVICE_USER}}
# cf_password: ${{secrets.CF_SERVICE_AUTH}}
# - name: monitor task output
# uses: cloud-gov/cg-cli-tools@main
# with:
# command: >
# scripts/monitor-cf-logs.sh harvesting-logic smoke-test
# cf_org: gsa-datagov
# cf_space: ${{vars.ENVIRONMENT_NAME}}
# cf_username: ${{secrets.CF_SERVICE_USER}}
# cf_password: ${{secrets.CF_SERVICE_AUTH}}
- name: Create Issue if it fails 😢
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }}
GITHUB_JOB: ${{ toJson(github)['job'] }}
GITHUB_ATTEMPTS: ${{ github.run_attempt }}
LAST_COMMIT: ${{ github.sha }}
LAST_RUN_BY: ${{ github.actor }}
RUN_ID: ${{ github.run_id }}
REPO: ${{ github.repository }}
with:
filename: .github/deploy_failure.md
update_existing: true