generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (49 loc) · 1.65 KB
/
job-nightly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Nightly
on:
schedule: [cron: "0 11 * * 6"] # 3 AM PST = 12 PM UDT, Saturdays
workflow_dispatch:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ageOutPRs:
name: PR Env Purge
env:
# https://tecadmin.net/getting-yesterdays-date-in-bash/
DATE: "4 days ago"
TYPE: "deployments"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- run: |
# Login to OpenShift
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ vars.OC_SERVER }}
oc project ${{ vars.OC_NAMESPACE }} # Safeguard!
oc get ${{ env.TYPE }} -o go-template --template '{{range .items}}{{.metadata.name}} {{.metadata.creationTimestamp}}{{"\n"}}{{end}}' | \
grep -v workspace | \
awk '$2 <= "'$(date -d '${{ env.DATE }}' -Ins --utc | sed 's/+0000/Z/')'" { print $1 }' | \
xargs --no-run-if-empty oc delete ${{ env.TYPE }}
# tests:
# name: Tests
# secrets: inherit
# uses: ./.github/workflows/.tests.yml
# with:
# target: test
# zap_scan:
# runs-on: ubuntu-latest
# name: Penetration Tests
# # Run after other tests to avoid rate limiting
# needs: [tests]
# env:
# DOMAIN: apps.silver.devops.gov.bc.ca
# PREFIX: ${{ github.event.repository.name }}-test
# steps:
# - name: ZAP Scan
# uses: zaproxy/[email protected]
# with:
# allow_issue_writing: true
# artifact_name: "zap_frontend"
# cmd_options: "-a"
# issue_title: "ZAP: frontend"
# target: https://${{ env.PREFIX }}-frontend.${{ env.DOMAIN }}