Skip to content

Commit e283983

Browse files
committed
ci: update build command for codeql
1 parent ad24efa commit e283983

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

.github/templates/onboarding-pr-body-automated.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
**This PR may be auto-merged in the future if not configured.**
44

55
If your team does not need the security scanner:
6-
- **Add a comment on this PR** explaining why your team is opting out
7-
- **Close this PR** to prevent auto-merge
8-
- **Add a `.github/no-security-scanner` file** to your repository to prevent future onboarding attempts
6+
1. **Add a comment on this PR** explaining why your team is opting out
7+
2. **Close this PR** to prevent auto-merge
8+
3. **Add a `.github/no-security-scanner` file** to your repository to prevent future onboarding attempts
99

1010
If you need the scanner but want to customize it:
11-
- Complete the checklist below
12-
- Review and modify the workflow file as needed
13-
- Approve and merge this PR when ready
11+
1. Complete the checklist below
12+
2. Review and modify the workflow file as needed
13+
3. Approve and merge this PR when ready
1414

1515
If no action is taken, this PR may be automatically merged after a grace period to ensure baseline security coverage across all repositories.
1616

@@ -19,7 +19,7 @@ If no action is taken, this PR may be automatically merged after a grace period
1919
## Required Action
2020

2121
Prior to merging this pull request, please ensure the following has been completed:
22-
- [ ] The lines specifying `branches` correctly specifies this repository's default branch (usually `main` or `master`).
22+
- [ ] The lines specifying `branches` correctly specify this repository's default branch (usually `main` or `master`).
2323
- [ ] Any paths you would like to ignore have been added to the `paths-ignored` configuration option (see [setup](https://github.com/MetaMask/action-security-code-scanner/blob/main/README.md#setup))
2424
- [ ] Language configuration has been reviewed - ignore falsely detected languages or add build commands for Java/Kotlin if needed (see Configuration section below)
2525
- [ ] Any existing CodeQL configuration has been disabled.
@@ -49,6 +49,7 @@ The scanner auto-detects languages in your repository. If you need to customize
4949
**Common use cases:**
5050

5151
1. **Ignore falsely detected languages:**
52+
5253
```yaml
5354
languages-config: |
5455
[
@@ -60,6 +61,7 @@ The scanner auto-detects languages in your repository. If you need to customize
6061
```
6162
6263
2. **Configure Java/Kotlin builds:**
64+
6365
```yaml
6466
languages-config: |
6567
[

.github/workflows/onboard-new-repo.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ on:
44
workflow_dispatch:
55
inputs:
66
repository:
7-
description: 'Repository to onboard (format: owner/repo)'
7+
description: 'Repository to onboard (format: owner/repo, e.g., MetaMask/snaps)'
88
required: true
99
type: string
10-
base_branch:
11-
description: 'Base branch to create PR against'
12-
required: false
13-
default: 'main'
14-
type: string
1510
repository_dispatch:
1611
types: [new_repository_created]
1712

@@ -31,13 +26,24 @@ jobs:
3126
id: target
3227
run: |
3328
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
34-
echo "repository=${{ github.event.client_payload.repository }}" >> $GITHUB_OUTPUT
35-
echo "base_branch=${{ github.event.client_payload.base_branch || 'main' }}" >> $GITHUB_OUTPUT
29+
REPO="${{ github.event.client_payload.repository }}"
30+
BASE_BRANCH="${{ github.event.client_payload.base_branch }}"
3631
else
37-
echo "repository=${{ inputs.repository }}" >> $GITHUB_OUTPUT
38-
echo "base_branch=${{ inputs.base_branch }}" >> $GITHUB_OUTPUT
32+
REPO="${{ inputs.repository }}"
33+
BASE_BRANCH=""
34+
fi
35+
36+
# If base_branch is not set, detect it from the repository
37+
if [ -z "$BASE_BRANCH" ]; then
38+
echo "Detecting default branch for $REPO..."
39+
BASE_BRANCH=$(gh api repos/$REPO --jq '.default_branch')
3940
fi
41+
42+
echo "repository=$REPO" >> $GITHUB_OUTPUT
43+
echo "base_branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
4044
shell: bash
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4147

4248
- name: Checkout target repository
4349
uses: actions/checkout@v4
@@ -65,16 +71,16 @@ jobs:
6571
git add .github/workflows/security-code-scanner.yml
6672
git commit -m "chore: add MetaMask Security Code Scanner workflow
6773
68-
This PR adds the MetaMask Security Code Scanner workflow to enable
69-
automated security scanning of the codebase.
74+
This PR adds the MetaMask Security Code Scanner workflow to enable
75+
automated security scanning of the codebase.
7076
71-
The scanner will run on:
72-
- Push to main branch
73-
- Pull requests to main branch
74-
- Manual workflow dispatch
77+
The scanner will run on:
78+
- Push to main branch
79+
- Pull requests to main branch
80+
- Manual workflow dispatch
7581
76-
To configure the scanner for your repository's specific needs,
77-
please review the workflow file and adjust as necessary."
82+
To configure the scanner for your repository's specific needs,
83+
please review the workflow file and adjust as necessary."
7884
7985
git push origin "$BRANCH_NAME"
8086
shell: bash

0 commit comments

Comments
 (0)