-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy to production using GitHub Actions (#1328)
Deploy to production using a deployment workflow trigger.
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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@v4 | ||
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.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@v2 | ||
- 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 15,23 * * *" bash openshift/scripts/oc_provision_bcfw_p1_forecasts_cronjob.sh prod apply | ||
PROJ_TARGET=e1e498-prod SCHEDULE="15 * * * *" bash openshift/scripts/oc_provision_bcfw_p1_hourly_actuals_cronjob.sh prod apply | ||
echo Configure backups | ||
PROJ_TARGET=e1e498-prod BACKUP_VOLUME_SIZE=50Gi CPU_REQUEST=1000m CPU_LIMIT=2000m bash openshift/scripts/oc_provision_backup_postgres.sh prod apply | ||
PROJ_TARGET=e1e498-prod CPU_REQUEST=1000m CPU_LIMIT=2000m bash openshift/scripts/oc_provision_backup_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@v4 | ||
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.repos.createDeploymentStatus({owner: context.repo.owner, repo: context.repo.repo, deployment_id: context.payload.deployment.id, state: 'success'})) | ||
console.log(status) |