-
Notifications
You must be signed in to change notification settings - Fork 911
chore(ci): add npm-audit-fix workflow
#3496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+89
β1
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: NPM Audit Fix | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 3 2,16 * *" | ||
| workflow_dispatch: | ||
| inputs: | ||
| force_fix: | ||
| description: "Run npm audit fix --force (includes breaking changes)" | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| permissions: {} # No permissions by default on workflow level | ||
|
|
||
| jobs: | ||
| npm-audit-fix: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read # to checkout code | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| lfs: true | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | ||
| with: | ||
| node-version-file: application/ui/.nvmrc | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: application/ui | ||
| run: npm ci | ||
|
|
||
| - name: Display audit report | ||
| working-directory: application/ui | ||
| continue-on-error: true | ||
| run: | | ||
| npm audit || true | ||
|
|
||
| - name: Run npm audit fix (safe mode) | ||
| if: ${{ github.event_name == 'schedule' || github.event.inputs.force_fix != 'true' }} | ||
| working-directory: application/ui | ||
| continue-on-error: true | ||
| run: npm audit fix --package-lock-only || echo "Some issues could not be auto-fixed" | ||
|
|
||
| - name: Run npm audit fix (force mode) | ||
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.force_fix == 'true' }} | ||
| working-directory: application/ui | ||
| continue-on-error: true | ||
| run: npm audit fix --force || true | ||
AlexanderBarabanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Check for changes | ||
| id: check-changes | ||
| working-directory: application/ui | ||
| run: | | ||
| if git diff --quiet package-lock.json package.json; then | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| # GitHub App token is required to trigger other workflows (GITHUB_TOKEN cannot trigger workflows) | ||
| - name: Get token | ||
| if: steps.check-changes.outputs.changed == 'true' | ||
| id: get-github-app-token | ||
| uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | ||
| with: | ||
| app-id: ${{ secrets.RENOVATE_APP_ID }} | ||
| private-key: ${{ secrets.RENOVATE_APP_PEM }} | ||
|
|
||
| - name: Create PR if lockfile changed | ||
| if: steps.check-changes.outputs.changed == 'true' | ||
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 | ||
| with: | ||
| token: ${{ steps.get-github-app-token.outputs.token }} | ||
| author: oep-renovate[bot] <212772560+oep-renovate[bot]@users.noreply.github.com> | ||
| committer: oep-renovate[bot] <212772560+oep-renovate[bot]@users.noreply.github.com> | ||
| commit-message: "fix(deps): npm audit fixes [security]" | ||
| title: "fix(deps): npm audit fixes [security]" | ||
| body: | | ||
| This PR was automatically created to update NPM dependencies with: | ||
| ${{ github.event.inputs.force_fix == 'true' && '`npm audit fix --force`' || '`npm audit fix --package-lock-only`' }} | ||
| branch: "npm-audit-fix-${{ github.run_id }}" | ||
| base: main | ||
| delete-branch: true | ||
AlexanderBarabanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.