Skip to content

Commit

Permalink
feat: output trigger results (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts authored Apr 4, 2024
1 parent 8ceca8b commit 8089260
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 34 deletions.
101 changes: 67 additions & 34 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull Request
name: PR

on:
pull_request:
Expand All @@ -11,46 +11,79 @@ env:
repo_builds: bcgov/quickstart-openshift

jobs:
deploys:
database:
name: Database
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
triggered: ${{ steps.triggered.outputs.triggered }}
steps:
- uses: actions/checkout@v4
- uses: ./
id: triggered
with:
file: templates/database.yml
name: database
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: false
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: 10
strategy:
matrix:
name: [database, backend, frontend]
include:
- name: database
file: templates/database.yml
overwrite: false
- name: backend
file: templates/backend.yml
overwrite: true
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
penetration_test: true
verification_path: /api
- name: frontend
file: templates/frontend.yml
oc_version: 4.13
overwrite: true
parameters: -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
timeout-minutes: 5
outputs:
triggered: ${{ steps.triggered.outputs.triggered }}
steps:
- uses: actions/checkout@v4
- name: Deploys
uses: ./
- uses: ./
id: triggered
with:
file: ${{ matrix.file }}
name: ${{ matrix.name }}
file: templates/frontend.yml
name: frontend
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
oc_version: ${{ matrix.oc_version }}
overwrite: ${{ matrix.overwrite }}
oc_version: 4.13
overwrite: true
parameters:
-p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}
${{ matrix.parameters }}
penetration_test: ${{ matrix.penetration_test }}
post_rollout: ${{ matrix.post_rollout }}
verification_path: ${{ matrix.verification_path }}
-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
results:
name: Results
needs: [database, backend, frontend]
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- run: |
echo "Results? ${{ toJson(needs) }}"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ deploys:
verification_url: health
```

# Output

The action will return a boolean (true|false) of whether a deployment has been triggered. It can be useful for follow-up tasks, like verifying job success.

```yaml
- id: meaningful_id_name
uses: bcgov-nr/[email protected]
...
- needs: [id]
run: |
echo "Triggered = ${{ steps.meaningful_id_name.outputs.triggered }}
```

# Route Verification vs Penetration Testing

Deployment templates are parsed for a route. If found, those routes are verified with a curl command for status code 200 (success). This ensures that applications are accessible from outside their OpenShift namespace/project.
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ inputs:
penetration_test_issue:
description: Provide a name to enable ZAProxy issue creation; e.g. frontend, backend

outputs:
triggered:
description: Did a deployment trigger? [true|false]
value: ${{ steps.diff.outputs.triggered }}

runs:
using: composite
steps:
Expand Down

0 comments on commit 8089260

Please sign in to comment.