-
Notifications
You must be signed in to change notification settings - Fork 9
71 lines (69 loc) · 4.22 KB
/
production.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
name: Production
# trigger this deployment by running:
# gh api repos/bcgov/wps/deployments -f ref="[your branch]"
# reference used to figure this part out:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#deployment
on: deployment
jobs:
deploy_to_production:
name: Deploy to production
runs-on: ubuntu-20.04
steps:
- name: Find PR number
uses: actions/github-script@v6
with:
# reference used to figure out this part:
# https://docs.github.com/en/rest/reference/pulls#list-pull-requests
# https://octokit.github.io/rest.js/v18#pulls
# https://github.com/actions/github-script
script: |
// get pull requests relating to this commit hash
const pulls = (await github.rest.repos.listPullRequestsAssociatedWithCommit({owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha }))
console.log(pulls)
// find an open PR (potentially problematic if you have multiple PR's on the same hash open!)
const pr = pulls.data.find( ({state}) => state === 'open')
core.exportVariable('SUFFIX', `pr-${pr.number}`);
- uses: actions/checkout@v3
- name: Provision to production
run: |
echo Login
oc login "${{ secrets.OPENSHIFT_CLUSTER }}" --token="${{ secrets.OC4_PROD_TOKEN }}"
echo Promote
bash openshift/scripts/oc_promote.sh ${SUFFIX} apply
bash openshift/scripts/oc_promote_ubuntu.sh ${SUFFIX} apply
echo Provision database
CPU_REQUEST=75m CPU_LIMIT=2000m MEMORY_REQUEST=2Gi MEMORY_LIMIT=16Gi PVC_SIZE=45Gi PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_db.sh prod apply
echo Deploy API
CPU_REQUEST=50m CPU_LIMIT=500m MEMORY_REQUEST=2Gi MEMORY_LIMIT=3Gi REPLICAS=3 PROJ_TARGET=e1e498-prod VANITY_DOMAIN=psu.nrs.gov.bc.ca SECOND_LEVEL_DOMAIN=apps.silver.devops.gov.bc.ca bash ./openshift/scripts/oc_deploy.sh prod apply
echo Env Canada Subscriber
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_ec_gdps_cronjob.sh prod apply
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_ec_hrdps_cronjob.sh prod apply
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_ec_rdps_cronjob.sh prod apply
echo C-Haines
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_provision_c_haines_cronjob.sh prod apply
echo BC FireWeather cronjobs
echo "Run forecast at 8h30 PDT and 16h30 PDT (so before and after noon)"
PROJ_TARGET=e1e498-prod SCHEDULE="30 * * * *" bash openshift/scripts/oc_provision_wfwx_noon_forecasts_cronjob.sh prod apply
PROJ_TARGET=e1e498-prod SCHEDULE="15 * * * *" bash openshift/scripts/oc_provision_wfwx_hourly_actuals_cronjob.sh prod apply
echo Configure backups
PROJ_TARGET=e1e498-prod CPU_REQUEST=1000m CPU_LIMIT=2000m bash openshift/scripts/oc_provision_backup_s3_postgres_cronjob.sh prod apply
PROJ_TARGET=e1e498-prod CPU_REQUEST=50m CPU_LIMIT=500m BACKUP_VOLUME_SIZE=3Gi bash openshift/scripts/oc_provision_backup_mariadb.sh prod apply
PROJ_TARGET=e1e498-prod CPU_REQUEST=50m CPU_LIMIT=500m bash openshift/scripts/oc_provision_backup_mariadb_cronjob.sh prod apply
echo Configure
PROJ_TARGET=e1e498-prod CERTBOT_STAGING=false DRYRUN=false bash openshift/scripts/oc_provision_certbot_cronjob.sh prod apply
set_deployment_status_success:
name: Set production deployment successful
needs: [deploy_to_production]
runs-on: ubuntu-20.04
steps:
- name: Set status to deployed
uses: actions/github-script@v6
with:
# reference used to figure out how to set the deployment status:
# https://docs.github.com/en/rest/reference/repos#deployments
# https://github.com/actions/github-script
# https://octokit.github.io/rest.js/v18#repos-create-deployment-status
script: |
console.log(context.payload)
const status = (await github.rest.repos.createDeploymentStatus({owner: context.repo.owner, repo: context.repo.repo, deployment_id: context.payload.deployment.id, state: 'success'}))
console.log(status)