Skip to content

production

production #744

Workflow file for this run

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-22.04
steps:
- name: Find PR number
uses: actions/github-script@v7
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@v4
- name: Provision to production
run: |
echo Login
oc login "${{ secrets.OPENSHIFT_CLUSTER }}" --token="${{ secrets.OC4_PROD_TOKEN }}"
PROJ_TARGET=e1e498-prod bash openshift/scripts/oc_deploy_to_production.sh ${SUFFIX} apply
set_deployment_status_success:
name: Set production deployment successful
needs: [deploy_to_production]
runs-on: ubuntu-22.04
steps:
- name: Set status to deployed
uses: actions/github-script@v7
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)