Skip to content

Commit

Permalink
chore(ci): updates (#76)
Browse files Browse the repository at this point in the history
* Remove old template

* pr-validate workflow

* Pare down pr-open.yml

* Shared workflow for pr-close.yml

* Rename merge workflow

* Move and rename unit-test.yml to analysis.yml

* Run Trivy and CodeQL in analysis workflow

* Pare down merge.yml

* Update prod release workflow

* vars.OC_SERVER

* PR Results job

* Scheduled.yml for PR expiry and ZAP tests
  • Loading branch information
DerekRoberts authored Mar 12, 2024
1 parent ecb35b1 commit da45b9c
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 362 deletions.
139 changes: 0 additions & 139 deletions .github/openshift/openshift.deploy.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Analysis

on:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
schedule:
- cron: "0 11 * * 0" # 3 AM PST = 12 PM UDT, runs sundays
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
codeql:
name: CodeQL Security Scan
if: ${{ ! github.event.pull_request.draft }}
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: javascript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:javascript"

# https://github.com/marketplace/actions/aqua-security-trivy
trivy:
name: Trivy Security Scan
if: ${{ ! github.event.pull_request.draft }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@0.18.0
with:
format: "sarif"
output: "trivy-results.sarif"
ignore-unfixed: true
scan-type: "fs"
scanners: "vuln,secret,config"
severity: "CRITICAL,HIGH"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"

results:
name: Analysis Results
needs: [codeql, trivy]
runs-on: ubuntu-22.04
steps:
- run: echo "Workflow completed successfully!"
67 changes: 0 additions & 67 deletions .github/workflows/merge-main.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Merge

on:
push:
branches: [main]
paths-ignore:
- ".github/ISSUE_TEMPLATE/*"
- "**.md"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
deploys-test:
name: TEST Deployments
environment: test
runs-on: ubuntu-22.04
strategy:
matrix:
name: [frontend, rctool]
include:
- name: frontend
file: frontend/openshift.nginx.deploy.yml
- name: rctool
file: frontend/openshift.deploy.yml
steps:
- uses: bcgov-nr/action-deployer-openshift@v2.1.0
with:
file: ${{ matrix.file }}
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: true
parameters:
-p ZONE=test -p PROMOTE=${{ github.repository }}/${{ matrix.name }}:test
-p NAME=${{ github.event.repository.name }}
46 changes: 12 additions & 34 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
name: Pull Request Closed
name: PR Closed

on:
pull_request:
types:
- closed
types: [closed]

concurrency:
# PR open and close use the same group, allowing only one at a time
group: pr-${{ github.ref }}
group: ${{ github.event.number }}
cancel-in-progress: true

jobs:
# Clean up OpenShift when PR closed, no conditions
cleanup-openshift:
name: Cleanup OpenShift
runs-on: ubuntu-22.04
steps:
- name: Remove OpenShift artifacts
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Remove old build runs, build pods and deployment pods
oc delete all,pvc,secret -l app=${{ github.event.repository.name }}-${{ github.event.number }}
# If merged into main, then handle any image promotions
image-promotions:
name: Image Promotions
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [frontend,rctool]
steps:
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ github.event.number }}
tags: test
cleanup:
name: Cleanup and Images
uses: bcgov/quickstart-openshift-helpers/.github/workflows/.pr-close.yml@v0.4.0
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
cleanup: label
packages: frontend rctool
Loading

0 comments on commit da45b9c

Please sign in to comment.