generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): shared and main merge workflows (#31)
- Loading branch information
1 parent
c2f5467
commit a02dc71
Showing
3 changed files
with
112 additions
and
73 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,80 @@ | ||
name: .Deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
### Required | ||
target: | ||
description: PR number, test or prod | ||
required: true | ||
type: string | ||
|
||
### Typical / recommended | ||
environment: | ||
description: GitHub environment; omit for PRs | ||
required: false | ||
type: string | ||
|
||
triggers: | ||
description: Bash array to diff for build triggering; omit to always fire | ||
required: false | ||
type: string | ||
|
||
verify: | ||
description: Run the cronjob and verify results? [true|false] | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
env: | ||
CRONJOB: ${{ github.event.repository.name }}-${{ inputs.target }}-sync | ||
JOB_JOB: ${{ github.event.repository.name }}-${{ inputs.target }}-sync-${{ github.run_number }} | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
environment: ${{ inputs.environment }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Deploy | ||
uses: bcgov-nr/action-deployer-openshift@v2.2.0 | ||
with: | ||
file: sync/openshift.etl.yml | ||
oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
oc_server: ${{ vars.OC_SERVER }} | ||
oc_token: ${{ secrets.OC_TOKEN }} | ||
oc_version: 4.13 | ||
overwrite: true | ||
parameters: -p ZONE=${{ inputs.target }} -p TAG=${{ inputs.target }} | ||
post_rollout: oc create job ${{ env.JOB_JOB }} --from=cronjob/${{ env.CRONJOB }} | ||
triggers: ${{ inputs.triggers }} | ||
|
||
verify: | ||
name: Verify | ||
if: inputs.verify == true | ||
environment: ${{ inputs.environment }} | ||
needs: [deploy] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Verify | ||
run: | | ||
# Check job logs | ||
# Login | ||
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }} | ||
oc project ${{ secrets.oc_namespace }} #Safeguard! | ||
# Follow | ||
oc wait --for=jsonpath='{.status.failed}'=4 job/${{ env.JOB_JOB }} --timeout=1m || true | ||
oc logs -l job-name=${{ env.JOB_JOB }} --tail=50 --follow | ||
# Results and exit code | ||
oc get job ${{ env.JOB_JOB }} | ||
if [ $(oc get job ${{ env.JOB_JOB }} -o jsonpath='{.status.ready}') -eq 0 ]; then | ||
echo "Job failed!" | ||
exit 1 | ||
else | ||
echo "Job successful!" | ||
exit 0 | ||
fi |
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
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