Skip to content

Commit 7430b11

Browse files
Cleanup of workflow files for Zizmor changes (#434)
1 parent 9f7a885 commit 7430b11

25 files changed

Lines changed: 486 additions & 312 deletions

.claude/commands/review-pr.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: Review the current pull request with comprehensive code analysis
55
You are conducting a thorough pull request code review for the Bitwarden gh-actions repository.
66

77
## Current Context
8+
89
- Repository: bitwarden/gh-actions
910
- This is a collection of reusable GitHub Actions workflows and custom actions
1011
- The code must follow Bitwarden's workflow linter rules
@@ -15,33 +16,39 @@ You are conducting a thorough pull request code review for the Bitwarden gh-acti
1516
Perform a comprehensive review of the current PR with focus on:
1617

1718
### 1. **Code Quality & Best Practices**
19+
1820
- Adherence to GitHub Actions best practices
1921
- Proper error handling and validation
2022
- Code maintainability and clarity
2123
- Appropriate use of GitHub Actions syntax
2224

2325
### 2. **Security Implications**
26+
2427
- No hardcoded secrets or credentials
2528
- Proper permission scoping
2629
- Input validation and sanitization
2730
- Protection against command injection
2831
- Safe handling of user-provided data
2932

3033
### 3. **Workflow Linter Compliance**
34+
3135
Verify compliance with Bitwarden workflow linter rules:
36+
3237
- Actions pinned to commit SHA with version comment
3338
- Permissions explicitly defined
3439
- Runner versions pinned (e.g., ubuntu-24.04)
3540
- Proper naming conventions (capitalized)
3641
- Only approved actions are used
3742

3843
### 4. **Performance & Efficiency**
44+
3945
- Appropriate caching strategies
4046
- Parallel job execution where possible
4147
- Minimal redundant operations
4248
- Efficient use of GitHub Actions resources
4349

4450
### 5. **Testing & Validation**
51+
4552
- Adequate test coverage for new features
4653
- Test workflows follow established patterns
4754
- Integration with existing test infrastructure
@@ -51,20 +58,24 @@ Verify compliance with Bitwarden workflow linter rules:
5158
Provide a structured review with:
5259

5360
1. **Summary of Changes**
61+
5462
- High-level overview of what this PR accomplishes
5563
- Key files modified and their impact
5664

5765
2. **Critical Issues** (if any)
66+
5867
- Security vulnerabilities
5968
- Breaking changes
6069
- Non-compliant code that must be fixed
6170

6271
3. **Suggested Improvements**
72+
6373
- Optimization opportunities
6474
- Better patterns or approaches
6575
- Documentation enhancements
6676

6777
4. **Good Practices Observed**
78+
6879
- Notable positive aspects (be concise)
6980
- Correct security implementations
7081
- Well-structured code

.claude/prompts/review-code.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Please review this pull request with a focus on:
2+
23
- Code quality and best practices
34
- Potential bugs or issues
45
- Security implications
@@ -7,6 +8,7 @@ Please review this pull request with a focus on:
78
Note: The PR branch is already checked out in the current working directory.
89

910
Provide a comprehensive review including:
11+
1012
- Summary of changes since last review
1113
- Critical issues found (be thorough)
1214
- Suggested improvements (be thorough)
@@ -15,6 +17,7 @@ Provide a comprehensive review including:
1517
- Leverage collapsible <details> sections where appropriate for lengthy explanations or code snippets to enhance human readability
1618

1719
When reviewing subsequent commits:
20+
1821
- Track status of previously identified issues (fixed/unfixed/reopened)
1922
- Identify NEW problems introduced since last review
2023
- Note if fixes introduced new issues

.editorconfig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ trim_trailing_whitespace = true
1414
insert_final_newline = true
1515
guidelines = 120
1616

17-
# JS files
17+
# JSON files
1818
[*.{json,yml}]
1919
indent_size = 2
20+
21+
# JS / TS / Markdown
22+
[*.{js,ts,md}]
23+
charset = utf-8
24+
indent_style = space
25+
indent_size = 2
26+
quote_type = single
Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,108 @@
1-
# Workflow templates are based on starter workflows provided by github at
2-
# https://github.com/actions/starter-workflows/tree/main and customized to
1+
# Workflow templates are based on starter workflows provided by github at
2+
# https://github.com/actions/starter-workflows/tree/main and customized to
33
# represent common practices used on ACME repositories.
44

55
# This imaginary workflow runs two steps and illustrates a number of options that we use throughout workflows in the Bitwarden repositories
66

77
name: Build
88

99
on: # Describes when to run the workflow
10-
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
10+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
1111

12-
workflow_dispatch: # When triggered manually
12+
workflow_dispatch: # When triggered manually
1313

14-
push: # On push to the following branches. Temporarily add a development branch to prompt workflow runs for troubleshooting
15-
branches: ["main", "rc", "hotfix-rc"]
16-
paths-ignore: # Updates to these directories or files will not trigger a workflow run
17-
- ".github/workflows/**"
14+
push: # On push to the following branches. Temporarily add a development branch to prompt workflow runs for troubleshooting
15+
branches: ["main", "rc", "hotfix-rc"]
16+
paths-ignore: # Updates to these directories or files will not trigger a workflow run
17+
- ".github/workflows/**"
1818

19-
# Pull_request_target: #We strongly discourage using this unless absolutely necessary as it requires access to certain Github secrets.
19+
# Pull_request_target: #We strongly discourage using this unless absolutely necessary as it requires access to certain Github secrets.
2020
# If using this, include the .github/workflows/check-run.yml job and target only the main branch
2121
# More info at https://github.blog/news-insights/product-news/github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks
2222

23-
pull_request: # When a pull request event occurs
24-
types: [opened, synchronize, unlabeled, labeled, unlabeled, reopened, edited]
25-
branches: ["main"] # Branches where a pull request will trigger the workflow
23+
pull_request: # When a pull request event occurs
24+
types:
25+
[
26+
opened,
27+
synchronize,
28+
unlabeled,
29+
labeled,
30+
unlabeled,
31+
reopened,
32+
edited,
33+
]
34+
branches: ["main"] # Branches where a pull request will trigger the workflow
2635

36+
release: # Runs your workflow when release activity in your repository occurs
37+
types: [published, created]
2738

28-
release: # Runs your workflow when release activity in your repository occurs
29-
types: [published, created]
39+
merge_group: # Runs required status checks on merge groups created by merge queue
40+
types: [checks_requested]
3041

31-
merge_group: # Runs required status checks on merge groups created by merge queue
32-
types: [checks_requested]
42+
repository_dispatch: # Runs when a webook event triggers a workflow from outside of github
43+
types: [contentful-publish] # Optional, limit repository dispatch events to those in a specified list
3344

34-
repository_dispatch: # Runs when a webook event triggers a workflow from outside of github
35-
types: [contentful-publish] # Optional, limit repository dispatch events to those in a specified list
36-
37-
workflow_call: # Workflow can be called by another workflow
45+
workflow_call: # Workflow can be called by another workflow
3846

3947
env: # Environment variables set for this step but not accessible by all workflows, steps or jobs.
40-
_AZ_REGISTRY: "ACMEprod.azurecr.io"
41-
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
48+
_AZ_REGISTRY: "ACMEprod.azurecr.io"
49+
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
4250

4351
jobs: # A workflow run is made up of one or more jobs that can run sequentially or in parallel
44-
first-job:
45-
name: First Job Name
46-
uses: ./.github/templates/workflow-templates/example-references/_version.yml # Path to an existing github action
47-
if: github.event.pull_request.draft == false # prevent part of a job from running on a draft PR
48-
secrets: inherit # When called by another workflow, pass all the calling workflow's secrets to the called workflow
49-
# "secrets" is only available for a reusable workflow call with "uses"
50-
strategy: # Create multiple job runs for each of a set of variables
51-
fail-fast: false # If true, cancel entire run if any job in the matrix fails
52-
matrix: # Matrix of variables used to define multiple job runs
53-
include:
54-
- project_name: Admin
55-
base_path: ./src
56-
node: true # Enables steps with if: ${{ matrix.node }}
57-
58-
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
59-
permissions: # Sets permissions of the GITHUB_TOKEN
60-
security-events: write # Allow actions to upload results to Github
61-
id-token: write # Required to fetch an OpenID Connect (OIDC) token
62-
contents: read # For actions/checkout to fetch code
63-
deployments: write # Permits an action to create a new deployment
64-
issues: write # Permits an action to create a new issue
65-
checks: write # Permits an action to create a check run
66-
actions: write # Permits an action to cancel a workflow run
67-
packages: read # Permits an action to access packages on GitHub Packages
68-
pull-requests: write # Permits an action to add a label to a pull request
69-
70-
# steps: when a reusable workflow is called with "uses", "steps" is not available
71-
second-job:
72-
name: Second Job Name
73-
runs-on: ubuntu-22.04 # The type of runner that the job will run on, not available if "uses" is used
74-
defaults:
75-
run: # Set the default shell and working directory
76-
shell: bash
77-
working-directory: "home/WorkingDirectory"
78-
79-
needs:
80-
- first-job # This job will wait until first-job completes
81-
# # # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory
82-
steps:
83-
- name: Descriptive step name
84-
# NOT RECOMMENDED if: always() # run even if previous steps failed or the workflow is canceled, this can cause a workflow run to hang indefinitely
85-
if: failure() # run when any previous step of a job fails
86-
# if: '!cancelled()' # run even if previous steps failed
87-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 Always pin a public action version to a full git SHA, followed by the version number in a comment. Version pins are insecure and can introduce vulnerabilities into workflows.
88-
with: # Parameters specific to this action that need to be defined in order for the step to be completed
89-
fetch-depth: 0 # Full git history for actions that rely on whether a change has occurred
90-
ref: ${{ github.event.pull_request.head.sha }}
91-
creds: ${{ secrets.SECRETS_OR_CREDENTIALS }}
92-
- name: Another descriptive step name
93-
# Run a script instead of an existing github action
94-
run: |
95-
whoami
96-
dotnet --info
97-
node --version
98-
npm --version
99-
echo "GitHub ref: $GITHUB_REF"
100-
echo "GitHub event: $GITHUB_EVENT"
52+
first-job:
53+
name: First Job Name
54+
uses: ./.github/templates/workflow-templates/example-references/_version.yml # Path to an existing github action
55+
if: github.event.pull_request.draft == false # prevent part of a job from running on a draft PR
56+
secrets: inherit # When called by another workflow, pass all the calling workflow's secrets to the called workflow
57+
# "secrets" is only available for a reusable workflow call with "uses"
58+
strategy: # Create multiple job runs for each of a set of variables
59+
fail-fast: false # If true, cancel entire run if any job in the matrix fails
60+
matrix: # Matrix of variables used to define multiple job runs
61+
include:
62+
- project_name: Admin
63+
base_path: ./src
64+
node: true # Enables steps with if: ${{ matrix.node }}
65+
66+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
67+
permissions: # Sets permissions of the GITHUB_TOKEN
68+
security-events: write # Allow actions to upload results to Github
69+
id-token: write # Required to fetch an OpenID Connect (OIDC) token
70+
contents: read # For actions/checkout to fetch code
71+
deployments: write # Permits an action to create a new deployment
72+
issues: write # Permits an action to create a new issue
73+
checks: write # Permits an action to create a check run
74+
actions: write # Permits an action to cancel a workflow run
75+
packages: read # Permits an action to access packages on GitHub Packages
76+
pull-requests: write # Permits an action to add a label to a pull request
77+
78+
# steps: when a reusable workflow is called with "uses", "steps" is not available
79+
second-job:
80+
name: Second Job Name
81+
runs-on: ubuntu-22.04 # The type of runner that the job will run on, not available if "uses" is used
82+
defaults:
83+
run: # Set the default shell and working directory
84+
shell: bash
85+
working-directory: "home/WorkingDirectory"
86+
87+
needs:
88+
- first-job # This job will wait until first-job completes
89+
# # # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory
90+
steps:
91+
- name: Descriptive step name
92+
# NOT RECOMMENDED if: always() # run even if previous steps failed or the workflow is canceled, this can cause a workflow run to hang indefinitely
93+
if: failure() # run when any previous step of a job fails
94+
# if: '!cancelled()' # run even if previous steps failed
95+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 Always pin a public action version to a full git SHA, followed by the version number in a comment. Version pins are insecure and can introduce vulnerabilities into workflows.
96+
with: # Parameters specific to this action that need to be defined in order for the step to be completed
97+
fetch-depth: 0 # Full git history for actions that rely on whether a change has occurred
98+
ref: ${{ github.event.pull_request.head.sha }}
99+
creds: ${{ secrets.SECRETS_OR_CREDENTIALS }}
100+
- name: Another descriptive step name
101+
# Run a script instead of an existing github action
102+
run: |
103+
whoami
104+
dotnet --info
105+
node --version
106+
npm --version
107+
echo "GitHub ref: $GITHUB_REF"
108+
echo "GitHub event: $GITHUB_EVENT"

.github/workflows/_checkmarx.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3737
with:
3838
ref: ${{ github.event.pull_request.head.sha }}
39+
persist-credentials: false
3940

4041
- name: Log in to Azure
4142
uses: bitwarden/gh-actions/azure-login@main

.github/workflows/_enforce-labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
- name: Check for label
1515
run: |
1616
echo "PRs with the hold label cannot be merged"
17-
echo "### :x: PRs with the hold label cannot be merged" >> $GITHUB_STEP_SUMMARY
17+
echo "### :x: PRs with the hold label cannot be merged" >> "$GITHUB_STEP_SUMMARY"
1818
exit 1

0 commit comments

Comments
 (0)