Skip to content

Commit

Permalink
chore: try out matrix with outputs (#83)
Browse files Browse the repository at this point in the history
Co-authored-by: Derek Roberts <[email protected]>
  • Loading branch information
mishraomp and DerekRoberts authored Apr 5, 2024
1 parent 8089260 commit 0e7fa88
Showing 1 changed file with 42 additions and 64 deletions.
106 changes: 42 additions & 64 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,61 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
repo_builds: bcgov/quickstart-openshift

jobs:
database:
name: Database
deploys:
runs-on: ubuntu-latest
timeout-minutes: 1
timeout-minutes: 10
outputs:
triggered: ${{ steps.triggered.outputs.triggered }}
backend: ${{ steps.trigger.outputs.backend }}
database: ${{ steps.trigger.outputs.database }}
frontend: ${{ steps.trigger.outputs.frontend }}
strategy:
matrix:
name: [ backend, database, frontend ]
include:
- name: backend
file: templates/backend.yml
overwrite: true
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
verification_path: /api
- name: database
file: templates/database.yml
overwrite: false
- name: frontend
file: templates/frontend.yml
oc_version: 4.13
overwrite: true
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
post_rollout: |
oc create job "frontend-$(date +%s)" --from=cronjob/${{ github.event.repository.name }}-${{ github.event.number }}-cronjob
steps:
- uses: actions/checkout@v4
- uses: ./
id: triggered
- id: deploys
uses: ./
with:
file: templates/database.yml
name: database
file: ${{ matrix.file }}
name: ${{ matrix.name }}
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: false
oc_version: ${{ matrix.oc_version }}
overwrite: ${{ matrix.overwrite }}
parameters: -p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}

backend:
name: Backend
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
triggered: ${{ steps.triggered.outputs.triggered }}
steps:
- uses: actions/checkout@v4
- uses: ./
id: triggered
with:
file: templates/backend.yml
name: backend
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: yes
parameters:
-p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}
-p MIN_REPLICAS=1 -p MAX_REPLICAS=2
penetration_test: true
verification_path: /api

frontend:
name: Deploys
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
triggered: ${{ steps.triggered.outputs.triggered }}
steps:
- uses: actions/checkout@v4
- uses: ./
id: triggered
with:
file: templates/frontend.yml
name: frontend
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
oc_version: 4.13
overwrite: true
parameters:
-p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}
-p MIN_REPLICAS=1 -p MAX_REPLICAS=2
penetration_test: false
post_rollout: |
oc create job "frontend-$(date +%s)" --from=cronjob/${{ github.event.repository.name }}-${{ github.event.number }}-cronjob
${{ matrix.parameters }}
penetration_test: ${{ matrix.penetration_test }}
post_rollout: ${{ matrix.post_rollout }}
verification_path: ${{ matrix.verification_path }}
- id: trigger
run: echo "${{ matrix.name }}=${{ steps.deploys.outputs.triggered }}" >> $GITHUB_OUTPUT

results:
name: Results
needs: [database, backend, frontend]
runs-on: ubuntu-latest
timeout-minutes: 1
needs: [deploys]
steps:
- run: |
echo "Results? ${{ toJson(needs) }}"
# Expand for outputs
echo "Results: ${{ toJson(needs.deploys.outputs) }}"
echo "Database triggered: ${{needs.deploys.outputs.database}}"
echo "Backend triggered: ${{needs.deploys.outputs.backend}}"
echo "Frontend triggered: ${{needs.deploys.outputs.frontend}}"

0 comments on commit 0e7fa88

Please sign in to comment.