Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: try out matrix with outputs #83

Merged
merged 8 commits into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}}"
Loading