-
Notifications
You must be signed in to change notification settings - Fork 9
50 lines (47 loc) · 2.26 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
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@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 }}"
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@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)