Skip to content

Commit 62ac388

Browse files
authored
fix(ci): introduce pr validate/edit workflow (#1781)
1 parent c19bc72 commit 62ac388

File tree

3 files changed

+92
-78
lines changed

3 files changed

+92
-78
lines changed

.github/workflows/analysis.yml

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,6 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
codeql:
18-
name: CodeQL
19-
if: ${{ ! github.event.pull_request.draft }}
20-
runs-on: ubuntu-22.04
21-
timeout-minutes: 5
22-
steps:
23-
- uses: actions/checkout@v4
24-
- uses: github/codeql-action/init@v3
25-
with:
26-
languages: javascript
27-
28-
- name: Perform CodeQL Analysis
29-
uses: github/codeql-action/analyze@v3
30-
with:
31-
category: "/language:javascript"
32-
33-
# https://github.com/marketplace/actions/aqua-security-trivy
34-
trivy:
35-
name: Trivy Security Scan
36-
if: ${{ ! github.event.pull_request.draft }}
37-
runs-on: ubuntu-22.04
38-
timeout-minutes: 1
39-
steps:
40-
- uses: actions/checkout@v4
41-
- name: Run Trivy vulnerability scanner in repo mode
42-
uses: aquasecurity/[email protected]
43-
with:
44-
format: "sarif"
45-
output: "trivy-results.sarif"
46-
ignore-unfixed: true
47-
scan-type: "fs"
48-
scanners: "vuln,secret,config"
49-
severity: "CRITICAL,HIGH"
50-
51-
- name: Upload Trivy scan results to GitHub Security tab
52-
uses: github/codeql-action/upload-sarif@v3
53-
with:
54-
sarif_file: "trivy-results.sarif"
55-
5617
tests:
5718
name: Tests
5819
if: ${{ ! github.event.pull_request.draft }}
@@ -96,10 +57,44 @@ jobs:
9657
sonar_token: ${{ secrets[matrix.token] }}
9758
triggers: ('${{ matrix.dir }}/')
9859

99-
results:
100-
name: Results
101-
needs: [codeql, trivy, tests]
60+
codeql:
61+
name: CodeQL
62+
if: ${{ ! github.event.pull_request.draft }}
63+
needs: [tests]
64+
runs-on: ubuntu-22.04
65+
timeout-minutes: 5
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: github/codeql-action/init@v3
69+
with:
70+
languages: javascript
71+
72+
- name: Perform CodeQL Analysis
73+
uses: github/codeql-action/analyze@v3
74+
with:
75+
category: "/language:javascript"
76+
77+
# https://github.com/marketplace/actions/aqua-security-trivy
78+
trivy:
79+
name: Trivy Security Scan
80+
if: ${{ ! github.event.pull_request.draft }}
81+
needs: [tests]
10282
runs-on: ubuntu-22.04
10383
timeout-minutes: 1
10484
steps:
105-
- run: echo "Success!"
85+
- uses: actions/checkout@v4
86+
- name: Run Trivy vulnerability scanner in repo mode
87+
uses: aquasecurity/[email protected]
88+
with:
89+
format: "sarif"
90+
output: "trivy-results.sarif"
91+
ignore-unfixed: true
92+
scan-type: "fs"
93+
scanners: "vuln,secret,config"
94+
severity: "CRITICAL,HIGH"
95+
96+
- name: Upload Trivy scan results to GitHub Security tab
97+
uses: github/codeql-action/upload-sarif@v3
98+
with:
99+
sarif_file: "trivy-results.sarif"
100+

.github/workflows/pr-open.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,6 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
conventional-commits:
13-
name: Conventional Commits
14-
runs-on: ubuntu-22.04
15-
steps:
16-
- uses: amannn/[email protected]
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
20-
pr-description-add:
21-
name: PR Description Add
22-
env:
23-
DOMAIN: apps.silver.devops.gov.bc.ca
24-
PREFIX: ${{ github.event.repository.name }}
25-
runs-on: ubuntu-22.04
26-
permissions:
27-
pull-requests: write
28-
timeout-minutes: 1
29-
steps:
30-
- uses: bcgov-nr/[email protected]
31-
with:
32-
add_markdown: |
33-
---
34-
35-
Thanks for the PR!
36-
37-
Deployments, as required, will be available below:
38-
- [Frontend](https://${{ env.PREFIX }}-${{ github.event.number }}-frontend.${{ env.DOMAIN }})
39-
- [Backend](https://${{ env.PREFIX }}-${{ github.event.number }}-frontend.${{ env.DOMAIN }}/api)
40-
41-
Please create PRs in draft mode. Mark as ready to enable:
42-
- [Analysis Workflow](https://github.com/${{ github.repository }}/actions/workflows/analysis.yml)
43-
44-
After merge, new images are deployed in:
45-
- [Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge.yml)
46-
4712
# https://github.com/bcgov-nr/action-builder-ghcr
4813
builds:
4914
name: Builds

.github/workflows/pr-validate.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: PR Validate
2+
3+
on:
4+
pull_request:
5+
types: [edited, opened, reopened, synchronize]
6+
7+
concurrency:
8+
# Cancel in progress for PR open and close, but not merge_group
9+
group: ${{ github.workflow }}-${{ github.event.number || github.event.merge_group.base_sha }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
# PR only, skip for merge_group
14+
conventional-commits:
15+
name: Conventional Commits
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: amannn/[email protected]
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- if: failure() && !success()
23+
run: |
24+
echo "Please use conventional commits in your PR title and re-run this job."
25+
echo "https://www.conventionalcommits.org/en/v1.0.0/"
26+
exit 1
27+
28+
# PR only, skip for merge_group
29+
pr-description-add:
30+
name: PR Description Add
31+
env:
32+
DOMAIN: apps.silver.devops.gov.bc.ca
33+
PREFIX: ${{ github.event.repository.name }}
34+
runs-on: ubuntu-22.04
35+
permissions:
36+
pull-requests: write
37+
timeout-minutes: 1
38+
steps:
39+
- uses: bcgov-nr/[email protected]
40+
with:
41+
add_markdown: |
42+
---
43+
44+
Thanks for the PR!
45+
46+
Deployments, as required, will be available below:
47+
- [Frontend](https://${{ env.PREFIX }}-${{ github.event.number }}-frontend.${{ env.DOMAIN }})
48+
- [Backend](https://${{ env.PREFIX }}-${{ github.event.number }}-frontend.${{ env.DOMAIN }}/api)
49+
50+
Please create PRs in draft mode. Mark as ready to enable:
51+
- [Analysis Workflow](https://github.com/${{ github.repository }}/actions/workflows/analysis.yml)
52+
53+
After merge, new images are deployed in:
54+
- [Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge.yml)

0 commit comments

Comments
 (0)