-
Notifications
You must be signed in to change notification settings - Fork 33
82 lines (77 loc) · 2.91 KB
/
devhub-scheduled-build.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
name: Scheduled Build/Deploy
on:
schedule:
- cron: '0 0 1,15 * *'
env:
ENVIRONMENT: prod
SUFFIX: prod
INFRA_NAME: devhub-app-web
ALGOLIA_INDEX_NAME: "Devhub-Algolia-prod"
jobs:
build:
name: Build Gatsby App
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Cluster Login
uses: redhat-developer/openshift-actions@v1.1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL }}
parameters: '{"apitoken": "${{ secrets.OPENSHIFT_SA_PASSWORD }}"}'
cmd: |
'version'
- name: Check if should run build (based on a commit id comparison)
env:
TOOLS_NAMESPACE: ${{ secrets.TOOLS_NAMESPACE }}
# reference https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
_commit=$(.github/helpers/get_last_build_commit_id.sh)
echo "BUILD_COMMIT_ID=$_commit" >> $GITHUB_ENV
- name: Create Build
env:
TOOLS_NAMESPACE: ${{ secrets.TOOLS_NAMESPACE }}
run: |
oc process -f openshift/templates/web/bc.yaml -n $TOOLS_NAMESPACE \
-p SUFFIX=$SUFFIX \
-p GATSBY_ALGOLIA_INDEX_NAME=${{ env.ALGOLIA_INDEX_NAME }} \
-p SOURCE_REPOSITORY_URL="https://github.com/$GITHUB_REPOSITORY" \
-p SOURCE_REPOSITORY_REF=master \
-p NAME=$INFRA_NAME \
-p VERSION="latest" | \
oc apply -n $TOOLS_NAMESPACE -f -
- name: Start Build (if needed)
if: env.BUILD_COMMIT_ID != github.sha
env:
TOOLS_NAMESPACE: ${{ secrets.TOOLS_NAMESPACE }}
run: |
echo "Build started"
oc start-build -n $TOOLS_NAMESPACE $INFRA_NAME$SUFFIX --wait
deploy:
needs: [ build ]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Cluster Login
uses: redhat-developer/openshift-actions@v1.1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_URL}}
parameters: '{"apitoken": "${{ secrets.OPENSHIFT_SA_PASSWORD }}"}'
cmd: |
'version'
- name: Run Deployment to Dev
env:
DEPLOY_NAMESPACE: ${{ secrets.DEV_NAMESPACE }}
SEARCHGATE_API_URL: ${{ secrets.SEARCHGATE_API_URL }}
DEVHUB_API_URL: ${{ secrets.DEVHUB_API_URL }}
SSO_BASE_URL: https://dev.oidc.gov.bc.ca
SSO_CLIENT_ID: "devhub-web-${{ env.PULL_NUMBER }}"
SSO_REALM_NAME: ${{ secrets.SSO_REALM }}
ALGOLIA_INDEX_NAME: "${{ env.ALGOLIA_INDEX_NAME }}"
IMAGE_NAMESPACE: ${{ secrets.TOOLS_NAMESPACE }}
IMAGE_TAG: latest
run: .github/helpers/deploy_web.sh
- name: Wait for Deployment
env:
NAMESPACE: ${{ secrets.DEV_NAMESPACE }}
run: |
DEPLOY_STATUS=$(.github/helpers/wait_for_deployment.sh dc/$INFRA_NAME$SUFFIX)