Skip to content

Commit e4c4958

Browse files
committed
add passing example workflows
1 parent 4d14d46 commit e4c4958

File tree

2 files changed

+117
-4
lines changed

2 files changed

+117
-4
lines changed

.github/templates/workflow-templates/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ permissions: # Sets permissions of the GITHUB_TOKEN
1717
jobs:
1818
version:
1919
name: Calculate version
20-
uses: ./.github/workflows/_version.yml # Path to an existing github action
20+
uses: ./.github/templates/workflow-templates/example-references/_version.yml # Path to an existing github action
2121

2222
test:
2323
name: Run test
24-
uses: ./.github/workflows/_test.yml
24+
uses: ./.github/templates/workflow-templates/example-references/_test.yml
2525
with: # Parameters specific to this action that need to be defined in order for the step to be completed
2626
project-name: Billing.Test
2727
project-path: ./test/Billing.Test
@@ -31,7 +31,7 @@ jobs:
3131
needs: # This job will not run until test and version jobs are complete
3232
- test
3333
- version
34-
uses: ./.github/workflows/_build.yml
34+
uses: ./.github/templates/workflow-templates/example-references/_build.yml
3535
with:
3636
project-name: Billing
3737
project-path: ./src/Billing
@@ -43,7 +43,7 @@ jobs:
4343
- test
4444
- version
4545
- build
46-
uses: ./.github/workflows/_docker.yml
46+
uses: ./.github/templates/workflow-templates/example-references/_docker.yml
4747
with:
4848
project-name: Billing
4949
project-path: ./src/Billing
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Workflow templates are based on starter workflows provided by github at
2+
# https://github.com/actions/starter-workflows/tree/main and customized to
3+
# represent common practices used on Bitwarden repositories.
4+
5+
# The Scan Workflow enables you to trigger SAST and quality scans directly
6+
# From the GitHub workflow.
7+
8+
name: Scan
9+
10+
on:
11+
# Controls when the workflow will run
12+
13+
# Can use other triggers such as multiple events, activity types and fiters:
14+
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#on
15+
workflow_dispatch: # When triggered manually
16+
17+
push: # On push to the following branches. Temporarily add a development branch to prompt workflow runs for troubleshooting
18+
branches:
19+
- "main"
20+
- "rc"
21+
- "hotfix-rc"
22+
pull_request_target: # When a pull request event occurs. Default is opened or reopened unless otherwise specified, as below:
23+
types: [opened, synchronize] # Other options include labeled, unlabeled, reopened
24+
branches: 'main'
25+
26+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
27+
jobs:
28+
# This workflow contains the jobs "check-run", "sast", and "quality"
29+
# This job is relatively simple and just imports a previously written action to be used in this workflow
30+
check-run: # You set this value with the name of the job you're describing
31+
name: Check PR run # Human readable descriptor
32+
uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main # location and branch of bitwarden-owned action being used
33+
34+
sast:
35+
# A more complex job that has multiple actions as steps described below
36+
name: SAST scan
37+
runs-on: ubuntu-22.04 # The type of runner that the job will run on
38+
needs: check-run # This job will wait until check-run completes
39+
permissions: # Sets permissions of the GITHUB_TOKEN
40+
contents: read # For actions/checkout to fetch code
41+
pull-requests: write # For github actions to upload feedback to PR
42+
security-events: write # For github/codeql-action/upload-sarif to upload SARIF results
43+
44+
# Steps represent a sequence of tasks that will be executed as part of the job
45+
steps:
46+
- name: Check out repo
47+
# Always pin a public action version to a full git SHA. Version pins are insecure and can introduce vulnerabilities into workflows.
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49+
with: # Parameters specific to this action that need to be defined in order for the step to be completed
50+
ref: ${{ github.event.pull_request.head.sha }}
51+
52+
- name: Scan with Checkmarx
53+
if: github.event.pull_request.draft == false # Prevent part of a job from running on a draft PR
54+
uses: checkmarx/ast-github-action@f0869bd1a37fddc06499a096101e6c900e815d81 # 2.0.36
55+
env: # Environment variables set for this step but not accessible by all workflows, steps or jobs
56+
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
57+
with:
58+
project_name: ${{ github.repository }}
59+
cx_tenant: ${{ secrets.CHECKMARX_TENANT }}
60+
base_uri: https://ast.checkmarx.net/
61+
cx_client_id: ${{ secrets.CHECKMARX_CLIENT_ID }}
62+
cx_client_secret: ${{ secrets.CHECKMARX_SECRET }}
63+
additional_params: |
64+
--report-format sarif \
65+
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
66+
--output-path . ${{ env.INCREMENTAL }}
67+
68+
- name: Upload Checkmarx results to GitHub
69+
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
70+
with:
71+
sarif_file: cx_result.sarif
72+
73+
quality:
74+
name: Quality scan
75+
runs-on: ubuntu-22.04
76+
needs: check-run
77+
permissions:
78+
contents: read
79+
pull-requests: write
80+
81+
steps:
82+
# Set up whatever resources your environment will need to run workflows on your code
83+
- name: Set up JDK 17
84+
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
85+
with:
86+
java-version: 17
87+
distribution: "zulu"
88+
# This step checks out a copy of your repository
89+
- name: Check out repo
90+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
91+
with:
92+
fetch-depth: 0 # Full git history for actions that rely on whether a change has occurred
93+
ref: ${{ github.event.pull_request.head.sha }}
94+
95+
- name: Set up .NET
96+
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
97+
# Install a tool without a Github Action
98+
- name: Install SonarCloud scanner
99+
run: dotnet tool install dotnet-sonarscanner -g
100+
101+
- name: Scan with SonarCloud
102+
env:
103+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
# Additional scripts to run outside of a Github Action
106+
run: |
107+
dotnet-sonarscanner begin /k:"${{ github.repository_owner }}_${{ github.event.repository.name }}" \
108+
/d:sonar.test.inclusions=test/,bitwarden_license/test/ \
109+
/d:sonar.exclusions=test/,bitwarden_license/test/ \
110+
/o:"${{ github.repository_owner }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
111+
/d:sonar.host.url="https://sonarcloud.io"
112+
dotnet build
113+
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)