Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions .github/workflows/npm-audit-fix.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://github.com/LibreCodeCoop/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
Expand All @@ -12,7 +12,7 @@ on:
workflow_dispatch:
schedule:
# At 2:30 on Sundays
- cron: "30 2 * * 0"
- cron: '30 2 * * 0'

permissions:
contents: read
Expand All @@ -26,38 +26,39 @@ jobs:
matrix:
branches:
- ${{ github.event.repository.default_branch }}
- "stable32"
- "stable31"
- "stable30"

name: npm-audit-fix-${{ matrix.branches }}

steps:
- name: Checkout
id: checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ matrix.branches }}
continue-on-error: true

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
if: steps.checkout.outcome == 'success'
uses: skjnldsv/read-package-engines-version-actions@06d6db44aa62f4609ba070f556ec24bc99fb85cb # v4
id: versions
with:
fallbackNode: "^20"
fallbackNpm: "^10"
fallbackNode: '^24'
fallbackNpm: '^11.3'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
if: steps.checkout.outcome == 'success'
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
if: steps.checkout.outcome == 'success'
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'

- name: Fix npm audit
id: npm-audit
if: steps.checkout.outcome == 'success'
uses: nextcloud-libraries/npm-audit-action@1b1728b2b4a7a78d69de65608efcf4db0e3e42d0 # v0.2.0

- name: Run npm ci and npm run build
Expand All @@ -68,17 +69,29 @@ jobs:
npm ci
npm run build --if-present

- name: Create GitHub App token for dependency PR
id: app-token
if: steps.checkout.outcome == 'success'
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }}
private-key: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
permission-contents: write
permission-pull-requests: write

- name: Create Pull Request
if: steps.checkout.outcome == 'success'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
commit-message: "fix(deps): Fix npm audit"
token: ${{ steps.app-token.outputs.token }}
commit-message: 'fix(deps): resolve npm audit vulnerabilities'
committer: GitHub <noreply@github.com>
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
signoff: true
branch: automated/noid/${{ matrix.branches }}-fix-npm-audit
title: "[${{ matrix.branches }}] Fix npm audit"
title: "${{ matrix.branches != github.event.repository.default_branch && format('[{0}] ', matrix.branches) || '' }}fix(deps): resolve npm audit vulnerabilities"
body: ${{ steps.npm-audit.outputs.markdown }}
labels: |
dependencies
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/npm-audit-fix.yml.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
# SPDX-License-Identifier: AGPL-3.0-or-later

--- a/.github/workflows/npm-audit-fix.yml
+++ b/.github/workflows/npm-audit-fix.yml
@@ -11,8 +11,8 @@
on:
workflow_dispatch:
schedule:
- # At 22:30 on Saturdays
- - cron: '30 22 * * 6'
+ # At 2:30 on Sundays
+ - cron: '30 2 * * 0'

permissions:
contents: read
@@ -95,3 +95,4 @@
body: ${{ steps.npm-audit.outputs.markdown }}
labels: |
dependencies
+ 3. to review
33 changes: 21 additions & 12 deletions .github/workflows/sync-workflow-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,40 @@ jobs:

steps:
- name: Check actor permission
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0
with:
require: admin
if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
permission="$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${GITHUB_ACTOR}/permission" --jq '.permission')"
[[ "${permission}" == "admin" ]] || {
echo "::error::Manual workflow runs require repository admin permission; ${GITHUB_ACTOR} has ${permission}"
exit 1
}

- name: Validate workflow sync authentication
shell: bash
env:
AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }}
LIBRECODE_APP_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_ID }}
LIBRECODE_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }}
LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }}
CONSUMER_APP_ID: ${{ vars.WORKFLOW_SYNC_APP_ID }}
CONSUMER_APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID }}
CONSUMER_APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }}
CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }}
run: |
set -euo pipefail

case "${AUTH_MODE}" in
librecode-app)
[[ -n "${LIBRECODE_APP_ID}" && -n "${LIBRECODE_APP_PRIVATE_KEY}" ]] || {
echo "::error::librecode-app requires LIBRECODE_WORKFLOW_APP_ID and LIBRECODE_WORKFLOW_APP_PRIVATE_KEY"
[[ -n "${LIBRECODE_APP_CLIENT_ID}" && -n "${LIBRECODE_APP_PRIVATE_KEY}" ]] || {
echo "::error::librecode-app requires LIBRECODE_WORKFLOW_APP_CLIENT_ID and LIBRECODE_WORKFLOW_APP_PRIVATE_KEY"
exit 1
}
;;
github-app)
[[ -n "${CONSUMER_APP_ID}" && -n "${CONSUMER_APP_PRIVATE_KEY}" ]] || {
echo "::error::github-app requires WORKFLOW_SYNC_APP_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY"
[[ -n "${CONSUMER_APP_CLIENT_ID}" && -n "${CONSUMER_APP_PRIVATE_KEY}" ]] || {
echo "::error::github-app requires WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY"
exit 1
}
;;
Expand All @@ -86,7 +94,7 @@ jobs:
id: librecode-app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ vars.LIBRECODE_WORKFLOW_APP_ID }}
client-id: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }}
private-key: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
Expand All @@ -99,7 +107,7 @@ jobs:
id: consumer-app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ vars.WORKFLOW_SYNC_APP_ID }}
client-id: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID }}
private-key: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
Expand Down Expand Up @@ -157,11 +165,12 @@ jobs:

- name: Synchronize workflow templates
id: sync
uses: LibreCodeCoop/.github/actions/sync-workflows@492e6c7c5a9bb7642f39238583003d2cb93f3ba6 # organization helpers
uses: ./source/actions/sync-workflows
with:
source: source/workflow-templates
target: target
catalog-commit: ${{ steps.catalog-revision.outputs.sha }}
include: npm-audit-fix.yml

- name: Create Pull Request
if: ${{ steps.sync.outputs.changed == 'true' }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/sync-workflow-templates.yml.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml
--- a/.github/workflows/sync-workflow-templates.yml
+++ b/.github/workflows/sync-workflow-templates.yml
@@ -26,6 +26,8 @@ jobs:
matrix:
branches:
- ${{ github.event.repository.default_branch }}
+ - 'stable32'
+ - 'stable31'
@@ -170,6 +170,7 @@
source: source/workflow-templates
target: target
catalog-commit: ${{ steps.catalog-revision.outputs.sha }}
+ include: npm-audit-fix.yml

name: Update workflows in ${{ matrix.branches }}
- name: Create Pull Request
if: ${{ steps.sync.outputs.changed == 'true' }}
Loading