From 84d4f897770885fdbb7179cfb7c9b806da2474e7 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:41:58 +0000 Subject: [PATCH 01/13] ci(deps): automate LibreSign submodule PR creation and safe regeneration Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/command-libresign-pr.yml | 158 +++++++++++++++++++++ .github/workflows/composer-auto.yml | 14 +- 2 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/command-libresign-pr.yml diff --git a/.github/workflows/command-libresign-pr.yml b/.github/workflows/command-libresign-pr.yml new file mode 100644 index 0000000..8669e19 --- /dev/null +++ b/.github/workflows/command-libresign-pr.yml @@ -0,0 +1,158 @@ +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +name: LibreSign PR comment + +on: + issue_comment: # zizmor: ignore[dangerous-triggers] + types: [created] + +permissions: + contents: read + +jobs: + init: + runs-on: ubuntu-latest + + # On pull requests and if the comment starts with `/libresign-pr` + if: github.event.issue.pull_request != '' && github.event.comment.body == '/libresign-pr' + + outputs: + head_ref: ${{ steps.comment-branch.outputs.head_ref }} + head_sha: ${{ steps.comment-branch.outputs.head_sha }} + base_ref: ${{ steps.comment-branch.outputs.base_ref }} + + steps: + - name: Get repository from pull request comment + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + id: get-repository + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const pull = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + + const repositoryName = pull.data.head?.repo?.full_name + console.log(repositoryName) + return repositoryName + + - name: Disabled on forks + if: ${{ fromJSON(steps.get-repository.outputs.result) != github.repository }} + run: | + echo 'Can not execute /libresign-pr on forks' + exit 1 + + - name: Check actor permission + uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0 + with: + require: write + + - name: Add reaction on start + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 + with: + token: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reactions: '+1' + + - name: Init branch + uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3.0.0 + id: comment-branch + + - name: Add reaction on failure + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 + if: failure() + with: + token: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reactions: '-1' + + process: + runs-on: ubuntu-latest + needs: init + + env: + HEAD_REF: ${{ needs.init.outputs.head_ref }} + HEAD_SHA: ${{ needs.init.outputs.head_sha }} + BASE_REF: ${{ needs.init.outputs.base_ref }} + PR_NUMBER: ${{ github.event.issue.number }} + PR_TITLE: ${{ github.event.issue.title }} + GH_TOKEN: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] + + steps: + - name: Checkout 3rdparty ${{ needs.init.outputs.head_ref }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: 3rdparty + persist-credentials: false + fetch-depth: 0 + ref: ${{ needs.init.outputs.head_sha }} + + - name: Set up php + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: 8.3 + coverage: none + + - name: Generate composer diff + working-directory: 3rdparty + run: | + composer global config --no-interaction allow-plugins.ion-bazan/composer-diff true + composer global require --no-interaction ion-bazan/composer-diff + { + echo "- [ ] 3rdparty: ${{ github.server_url }}/${{ github.repository }}/pull/$PR_NUMBER" + echo + composer diff --with-links --base "origin/$BASE_REF:composer.lock" --target composer.lock + } > "$RUNNER_TEMP/pr-body.md" + cat "$RUNNER_TEMP/pr-body.md" + + - name: Checkout LibreSign ${{ needs.init.outputs.base_ref }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: LibreSign/libresign + path: libresign + persist-credentials: true + # Pushing a new branch to LibreSign needs the `workflow` scope, as GitHub can not always verify in time that no workflow is changed + token: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] + ref: ${{ needs.init.outputs.base_ref }} + + - name: Fail if branch already exists on LibreSign + working-directory: libresign + run: | + if git ls-remote --exit-code --heads origin "refs/heads/$HEAD_REF"; then + echo "Branch $HEAD_REF already exists on LibreSign/libresign, not overwriting it" + exit 1 + fi + + - name: Setup git + working-directory: libresign + run: | + git config --local user.email 'libresign-command@users.noreply.github.com' + git config --local user.name 'libresign-command' + + - name: Commit 3rdparty update and push + working-directory: libresign + run: | + git checkout -b "$HEAD_REF" + git update-index --cacheinfo "160000,$HEAD_SHA,3rdparty" + git commit --signoff -m "$(sed -E 's/^\[stable[0-9.]*\] *//' <<< "$PR_TITLE")" + git push origin "$HEAD_REF" + + - name: Create LibreSign pull request + run: | + url=$(gh pr create --repo LibreSign/libresign --base "$BASE_REF" --head "$HEAD_REF" \ + --title "$PR_TITLE" \ + --body-file "$RUNNER_TEMP/pr-body.md") + gh pr comment "$PR_NUMBER" --repo '${{ github.repository }}' --body "- LibreSign PR: $url" + + - name: Add reaction on failure + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 + if: failure() + with: + token: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] + repository: '${{ github.event.repository.full_name }}' + comment-id: '${{ github.event.comment.id }}' + reactions: '-1' diff --git a/.github/workflows/composer-auto.yml b/.github/workflows/composer-auto.yml index e29a28c..808540d 100644 --- a/.github/workflows/composer-auto.yml +++ b/.github/workflows/composer-auto.yml @@ -106,11 +106,17 @@ jobs: - name: Dump Autoload run: composer dump-autoload - - name: Commit and push amend + - name: Commit and push regenerated dependencies + env: + HEAD_REF: ${{ needs.init.outputs.head_ref }} run: | - git add . - git commit --signoff -m 'chore(autoloader): Dump autoloader' - git push --force origin '${{ needs.init.outputs.head_ref }}' + git add -A + if git diff --cached --quiet; then + echo 'No regenerated files changed' + exit 0 + fi + git commit --signoff -m 'chore(autoloader): Regenerate scoped dependencies' + git push origin "HEAD:$HEAD_REF" - name: Add reaction on failure uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 From 33cd9aaea23e0e9c8738628a07815f7a32775bf9 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:42:49 +0000 Subject: [PATCH 02/13] ci(deps): cover main and stable35 and document integration workflow Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/dependabot.yml | 25 +++++++++++++++++++++---- .github/workflows/composer.yml | 2 +- README.md | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a59fb53..c2d1f49 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -19,7 +19,6 @@ updates: versioning-strategy: "increase" labels: - "dependencies" - - "main" groups: symfony: applies-to: version-updates @@ -41,7 +40,6 @@ updates: update-types: ["version-update:semver-major", "version-update:semver-minor"] labels: - "dependencies" - - "stable32" groups: symfony: applies-to: version-updates @@ -63,7 +61,6 @@ updates: update-types: ["version-update:semver-major", "version-update:semver-minor"] labels: - "dependencies" - - "stable33" groups: symfony: applies-to: version-updates @@ -85,7 +82,27 @@ updates: update-types: ["version-update:semver-major", "version-update:semver-minor"] labels: - "dependencies" - - "stable34" + groups: + symfony: + applies-to: version-updates + patterns: + - "symfony/*" + +- package-ecosystem: composer + directory: "/" + target-branch: stable35 + schedule: + interval: "weekly" + open-pull-requests-limit: 20 + commit-message: + prefix: "build" + include: "scope" + versioning-strategy: "increase" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major", "version-update:semver-minor"] + labels: + - "dependencies" groups: symfony: applies-to: version-updates diff --git a/.github/workflows/composer.yml b/.github/workflows/composer.yml index e050f6e..4eac055 100644 --- a/.github/workflows/composer.yml +++ b/.github/workflows/composer.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - master + - main - stable* permissions: diff --git a/README.md b/README.md index a6dbf7d..5cc76b2 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,28 @@ php -d error_reporting=E_ALL\&~E_DEPRECATED\&~E_USER_DEPRECATED \ composer dump-autoload -o ``` +## Pull request automation + +Dependabot proposes dependency upgrades for `main` and maintained stable branches. +For a dependency PR opened from a branch in this repository, a maintainer with +write access can comment `/composer-update` to rebuild the scoped dependencies +and autoload files. The command commits generated changes to the same PR branch +without rewriting existing commits. + +Once the scoped dependency changes are ready, comment `/libresign-pr` on the +3rdparty PR to create a corresponding PR in `LibreSign/libresign`. The target +branch must exist in both repositories. This creates a PR for review; it does +not merge either PR. + +After the 3rdparty PR is merged, comment `/update-3rdparty` on the linked +LibreSign PR to point its submodule at the merged 3rdparty commit. Never update +the submodule to an unrelated branch tip. Both repositories' checks and reviews +must pass before merging the application PR. + +The commands require a maintainer and a branch hosted in the repository; pull +requests from forks are intentionally excluded. If a command cannot run, use +the manual steps below. + ## Testing your PR with LibreSign 1. On https://github.com/libresign/libresign make a new branch `3rdparty/my-dependency` From 5164beea1d30fa23045af22ced9fbfb4d0d671a9 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:03:32 +0000 Subject: [PATCH 03/13] docs: prioritize automated dependency update workflow Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- README.md | 173 +++++++++++++++++++----------------------------------- 1 file changed, 60 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index 5cc76b2..4d5e29f 100644 --- a/README.md +++ b/README.md @@ -1,120 +1,67 @@ # LibreSign 3rdparty -Scoped 3rd party libraries that are necessary to run the LibreSign Nextcloud app. +Vendored Composer dependencies for the LibreSign Nextcloud app. PHP-Scoper +isolates these libraries under `OCA\Libresign\Vendor\` to avoid namespace +conflicts with Nextcloud and other apps. + +## Updating dependencies + +Dependabot proposes updates for `main` and maintained stable branches. The +usual workflow is: + +1. Review the dependency version and lockfile changes in the + [3rdparty pull request](https://github.com/LibreSign/3rdparty/pulls). +2. A maintainer comments `/composer-update` on that PR to regenerate the + vendored, scoped libraries and autoload files. Wait for the 3rdparty CI. +3. Comment `/libresign-pr` on the same PR to create a matching pull request + in [LibreSign](https://github.com/LibreSign/libresign/pulls), targeting + the corresponding branch and pointing to the proposed 3rdparty commit. +4. Review and test the integration in LibreSign. After approval, merge the + 3rdparty PR first. +5. Comment `/update-3rdparty` on the linked LibreSign PR to update its + submodule pointer to the exact commit integrated into 3rdparty. + Wait for the new LibreSign CI checks before merging that PR. + +These commands are restricted to maintainers and pull-request branches hosted +in the respective repositories. They create or update PRs; **they do not merge +anything automatically**. For forks or unavailable automation, use the manual +procedure below. + +### Manual fallback + +In a clean, disposable 3rdparty working tree: + +1. Update the version constraint in `composer.json`, if needed, and run + `composer update vendor/package`. +2. Remove the generated `composer/*/` and `vendor/*/` directories, then run + `composer install --no-dev`. The Composer scripts execute PHP-Scoper. +3. Run `git clean -X -d -f` and `composer dump-autoload -o`. **Note:** + `git clean -X` permanently removes ignored files; inspect the working + tree first. +4. Commit the changed manifest, lockfile and generated dependencies with DCO + sign-off, then open a 3rdparty PR. +5. In `LibreSign/libresign`, create a separate branch and PR updating only + the `3rdparty` submodule to the candidate commit. After the 3rdparty PR + is merged, add another signed-off commit pointing to the integrated SHA. + Rerun LibreSign CI before merging. + +Do not amend or force-push merely to update the submodule pointer. + +## PHP-Scoper + +- Dependency requirements are defined in `composer.json`; downloaded sources + live in `vendor/`, and scoped output is generated in `composer/`. +- `scoper.inc.php` contains namespace rules and special handling for Twig, + mPDF, phpseclib and PDFParser. +- Composer's `post-install-cmd` and `post-update-cmd` regenerate the scoped + libraries. Do not hand-edit generated dependencies. + +For troubleshooting, PHP-Scoper can also be invoked explicitly after +installing its tooling: -This repository contains vendor dependencies processed with PHP-Scoper to avoid conflicts with Nextcloud core and other apps. All classes are prefixed with `OCA\Libresign\Vendor\`. - -## Structure - -The LibreSign 3rdparty repository has a different structure compared to Nextcloud's 3rdparty: - -- **Scoped dependencies**: Located in `composer/` directory (not root) -- **Source dependencies**: Located in `vendor/` directory -- **Scoper configuration**: Uses `scoper.inc.php` to apply namespace transformations -- **Automatic processing**: PHP-Scoper runs automatically via composer scripts - -## Updating libraries manually - -1. Make sure to use the latest version of composer: `composer self-update` -2. Edit composer.json and adjust the version of the library to the one to update to. Pay attention to use the full version number (i.e. ^5.3.14). -3. Run `composer update thevendor/thelib` (replace accordingly) -4. Delete all installed dependencies with `rm -rf ./composer/*/ ./vendor/*/` -5. Run `composer install --no-dev` - - This automatically runs PHP-Scoper via post-install-cmd script - - Scoped dependencies are generated in `composer/` directory -6. Run `git clean -X -d -f` -7. Run `composer dump-autoload` -8. Commit all changes onto a new branch -9. You might need the following command for pushing if used as submodule: `git push git@github.com:libresign/3rdparty.git branchname` - -## PHP-Scoper Integration - -This repository uses PHP-Scoper to avoid namespace conflicts with Nextcloud core and other apps: - -- **Namespace prefix**: `OCA\Libresign\Vendor\` -- **Configuration**: See `scoper.inc.php` for scoping rules and patchers -- **Output directory**: `composer/` (configured in scoper.inc.php) -- **Automatic execution**: Runs via composer post-install-cmd and post-update-cmd scripts - -### Scoper Patchers - -The `scoper.inc.php` file includes specific patchers for: -- **Twig**: Handles template compilation and function calls -- **Mpdf**: Manages PDF generation library scoping -- **phpseclib**: Cryptographic library adjustments -- **pdfparser**: PDF parsing functionality - -### Manual Scoper Execution - -If you need to run PHP-Scoper manually: - -```bash -# Install scoper dependencies first +```sh composer bin all install --ansi - -# Run scoper manually -php -d error_reporting=E_ALL\&~E_DEPRECATED\&~E_USER_DEPRECATED \ +php -d error_reporting=E_ALL\&`E_DEPRECATED\&`E_USER_DEPRECATED \ vendor-bin/php-scoper/vendor/humbug/php-scoper/bin/php-scoper add-prefix --force - -# Regenerate autoload composer dump-autoload -o ``` - -## Pull request automation - -Dependabot proposes dependency upgrades for `main` and maintained stable branches. -For a dependency PR opened from a branch in this repository, a maintainer with -write access can comment `/composer-update` to rebuild the scoped dependencies -and autoload files. The command commits generated changes to the same PR branch -without rewriting existing commits. - -Once the scoped dependency changes are ready, comment `/libresign-pr` on the -3rdparty PR to create a corresponding PR in `LibreSign/libresign`. The target -branch must exist in both repositories. This creates a PR for review; it does -not merge either PR. - -After the 3rdparty PR is merged, comment `/update-3rdparty` on the linked -LibreSign PR to point its submodule at the merged 3rdparty commit. Never update -the submodule to an unrelated branch tip. Both repositories' checks and reviews -must pass before merging the application PR. - -The commands require a maintainer and a branch hosted in the repository; pull -requests from forks are intentionally excluded. If a command cannot run, use -the manual steps below. - -## Testing your PR with LibreSign - -1. On https://github.com/libresign/libresign make a new branch `3rdparty/my-dependency` -2. Navigate into the 3rdparty directory -3. Checkout the commit sha of the **last commit** of your PR in the 3rdparty repository -4. Leave the directory -5. Add the change to the stash -6. Commit (with sign-off and message) -7. Push the branch and send a PR -8. ⏳ Wait for CI and reviews -9. Navigate into the 3rdparty directory -10. Checkout the commit sha of the **merge commit** of your PR in the 3rdparty repository -11. Leave the directory -12. Add the change to the stash -13. Amend to the previous dependency bump -14. Push with lease force -15. ⏳ Wait for CI -16. Merge 🎉 - -```sh -cd 3rdparty -git checkout 16cd747ebb8ab4d746193416aa2448c8114d5084 -cd .. -git add 3rdparty -git commit -git push origin 3rdparty/my-dependency - -# Wait for CI and reviews - -cd 3rdparty -git checkout 54b63cc87af3ddb0ddfa331f20ecba5fcc01d495 -cd .. -git add 3rdparty -git commit --amend -git push --force-with-lease origin 3rdparty/my-dependency -``` From 97b7ad9d843649eccbc6cbf60b1e54808a5f4da1 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:03:45 +0000 Subject: [PATCH 04/13] docs: preserve PHP-Scoper diagnostic command Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d5e29f..7943df7 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ installing its tooling: ```sh composer bin all install --ansi -php -d error_reporting=E_ALL\&`E_DEPRECATED\&`E_USER_DEPRECATED \ +php -d error_reporting=E_ALL\&~E_DEPRECATED\&~E_USER_DEPRECATED \ vendor-bin/php-scoper/vendor/humbug/php-scoper/bin/php-scoper add-prefix --force composer dump-autoload -o ``` From 99016c9b4e08869a280aa82ddf44a2d76d276a78 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:25:15 +0000 Subject: [PATCH 05/13] ci(deps): consume shared Nextcloud-derived submodule PR workflow Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- ...resign-pr.yml => command-submodule-pr.yml} | 71 ++++--- .../workflows/command-submodule-pr.yml.patch | 22 ++ .github/workflows/sync-workflow-templates.yml | 193 ++++++++++++++++++ .../sync-workflow-templates.yml.patch | 30 +++ 4 files changed, 285 insertions(+), 31 deletions(-) rename .github/workflows/{command-libresign-pr.yml => command-submodule-pr.yml} (69%) create mode 100644 .github/workflows/command-submodule-pr.yml.patch create mode 100644 .github/workflows/sync-workflow-templates.yml create mode 100644 .github/workflows/sync-workflow-templates.yml.patch diff --git a/.github/workflows/command-libresign-pr.yml b/.github/workflows/command-submodule-pr.yml similarity index 69% rename from .github/workflows/command-libresign-pr.yml rename to .github/workflows/command-submodule-pr.yml index 8669e19..3d75214 100644 --- a/.github/workflows/command-libresign-pr.yml +++ b/.github/workflows/command-submodule-pr.yml @@ -1,6 +1,6 @@ -# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors -# SPDX-License-Identifier: AGPL-3.0-or-later -name: LibreSign PR comment +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT +name: Open submodule pull request on: issue_comment: # zizmor: ignore[dangerous-triggers] @@ -11,9 +11,9 @@ permissions: jobs: init: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low - # On pull requests and if the comment starts with `/libresign-pr` + # A consumer patch or repository variable configures the command. if: github.event.issue.pull_request != '' && github.event.comment.body == '/libresign-pr' outputs: @@ -41,7 +41,7 @@ jobs: - name: Disabled on forks if: ${{ fromJSON(steps.get-repository.outputs.result) != github.repository }} run: | - echo 'Can not execute /libresign-pr on forks' + echo 'Can not execute /server-pr on forks' exit 1 - name: Check actor permission @@ -71,22 +71,30 @@ jobs: reactions: '-1' process: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: init env: + TARGET_REPOSITORY: LibreSign/libresign + SUBMODULE_PATH: 3rdparty HEAD_REF: ${{ needs.init.outputs.head_ref }} HEAD_SHA: ${{ needs.init.outputs.head_sha }} BASE_REF: ${{ needs.init.outputs.base_ref }} PR_NUMBER: ${{ github.event.issue.number }} PR_TITLE: ${{ github.event.issue.title }} - GH_TOKEN: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] steps: + - name: Validate target configuration + shell: bash + run: | + set -euo pipefail + [[ "$TARGET_REPOSITORY" =~ ^[[:alnum:]_.-]+/[[:alnum:]_.-]+$ ]] || exit 1 + [[ "$SUBMODULE_PATH" =~ ^[[:alnum:]_.-]+(/[[:alnum:]_.-]+)*$ ]] || exit 1 + - name: Checkout 3rdparty ${{ needs.init.outputs.head_ref }} uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - path: 3rdparty + path: source persist-credentials: false fetch-depth: 0 ref: ${{ needs.init.outputs.head_sha }} @@ -98,55 +106,56 @@ jobs: coverage: none - name: Generate composer diff - working-directory: 3rdparty + working-directory: source run: | composer global config --no-interaction allow-plugins.ion-bazan/composer-diff true composer global require --no-interaction ion-bazan/composer-diff { - echo "- [ ] 3rdparty: ${{ github.server_url }}/${{ github.repository }}/pull/$PR_NUMBER" + echo "- [ ] $SUBMODULE_PATH: ${{ github.server_url }}/${{ github.repository }}/pull/$PR_NUMBER" echo composer diff --with-links --base "origin/$BASE_REF:composer.lock" --target composer.lock } > "$RUNNER_TEMP/pr-body.md" cat "$RUNNER_TEMP/pr-body.md" - - name: Checkout LibreSign ${{ needs.init.outputs.base_ref }} + - name: Checkout target repository ${{ needs.init.outputs.base_ref }} uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - repository: LibreSign/libresign - path: libresign - persist-credentials: true - # Pushing a new branch to LibreSign needs the `workflow` scope, as GitHub can not always verify in time that no workflow is changed - token: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] + repository: ${{ env.TARGET_REPOSITORY }} + path: parent + persist-credentials: false ref: ${{ needs.init.outputs.base_ref }} - - name: Fail if branch already exists on LibreSign - working-directory: libresign + - name: Fail if target branch already exists + working-directory: parent run: | if git ls-remote --exit-code --heads origin "refs/heads/$HEAD_REF"; then - echo "Branch $HEAD_REF already exists on LibreSign/libresign, not overwriting it" + echo "Branch $HEAD_REF already exists on $TARGET_REPOSITORY, not overwriting it" exit 1 fi - name: Setup git - working-directory: libresign + working-directory: parent run: | - git config --local user.email 'libresign-command@users.noreply.github.com' - git config --local user.name 'libresign-command' + git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' + git config --local user.name 'github-actions[bot]' - - name: Commit 3rdparty update and push - working-directory: libresign + - name: Commit submodule reference + working-directory: parent run: | git checkout -b "$HEAD_REF" - git update-index --cacheinfo "160000,$HEAD_SHA,3rdparty" + git update-index --cacheinfo "160000,$HEAD_SHA,$SUBMODULE_PATH" git commit --signoff -m "$(sed -E 's/^\[stable[0-9.]*\] *//' <<< "$PR_TITLE")" - git push origin "$HEAD_REF" - - - name: Create LibreSign pull request + - name: Push branch and create target pull request + env: + GH_TOKEN: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] run: | - url=$(gh pr create --repo LibreSign/libresign --base "$BASE_REF" --head "$HEAD_REF" \ + set -euo pipefail + gh auth setup-git + git -C parent push origin "$HEAD_REF" + url=$(gh pr create --repo "$TARGET_REPOSITORY" --base "$BASE_REF" --head "$HEAD_REF" \ --title "$PR_TITLE" \ --body-file "$RUNNER_TEMP/pr-body.md") - gh pr comment "$PR_NUMBER" --repo '${{ github.repository }}' --body "- LibreSign PR: $url" + gh pr comment "$PR_NUMBER" --repo '${{ github.repository }}' --body "- Parent PR: $url" - name: Add reaction on failure uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 diff --git a/.github/workflows/command-submodule-pr.yml.patch b/.github/workflows/command-submodule-pr.yml.patch new file mode 100644 index 0000000..20f2f72 --- /dev/null +++ b/.github/workflows/command-submodule-pr.yml.patch @@ -0,0 +1,22 @@ +--- a/.github/workflows/command-submodule-pr.yml ++++ b/.github/workflows/command-submodule-pr.yml +@@ -14,7 +14,7 @@ + runs-on: ubuntu-latest-low + + # A consumer patch or repository variable configures the command. ++ if: github.event.issue.pull_request != '' && github.event.comment.body == '/libresign-pr' +- if: github.event.issue.pull_request != '' && vars.SUBMODULE_PR_COMMAND != '' && github.event.comment.body == vars.SUBMODULE_PR_COMMAND + + outputs: + head_ref: ${{ steps.comment-branch.outputs.head_ref }} +@@ -75,8 +75,8 @@ + needs: init + + env: ++ TARGET_REPOSITORY: LibreSign/libresign ++ SUBMODULE_PATH: 3rdparty +- TARGET_REPOSITORY: ${{ vars.SUBMODULE_TARGET_REPOSITORY }} +- SUBMODULE_PATH: ${{ vars.SUBMODULE_PATH }} + HEAD_REF: ${{ needs.init.outputs.head_ref }} + HEAD_SHA: ${{ needs.init.outputs.head_sha }} + BASE_REF: ${{ needs.init.outputs.base_ref }} diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml new file mode 100644 index 0000000..c95acc9 --- /dev/null +++ b/.github/workflows/sync-workflow-templates.yml @@ -0,0 +1,193 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/LibreCodeCoop/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +# This workflow will update all workflow templates. +# Additionally it will reapply workflow.yml.patch files after syncing and only then commit the result. +# +# Authentication is selected explicitly with vars.WORKFLOW_SYNC_AUTH_MODE. +# See docs/cross-repository-automation.md for modes, credentials and GITHUB_TOKEN limitations. +name: Update workflows +on: + workflow_dispatch: + schedule: + - cron: "5 2 * * 0" + +permissions: + contents: read + +jobs: + dispatch: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + branches: + - ${{ github.event.repository.default_branch }} + + name: Update workflows in ${{ matrix.branches }} + + permissions: + contents: write + pull-requests: write + + steps: + - name: Check actor permission + 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 || 'token' }} + LIBRECODE_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} + LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} + 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 || secrets.COMMAND_BOT_PAT }} + run: | + set -euo pipefail + + case "${AUTH_MODE}" in + librecode-app) + [[ -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_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 + } + ;; + token) + [[ -n "${CONSUMER_TOKEN}" ]] || { + echo "::error::token mode requires WORKFLOW_SYNC_TOKEN" + exit 1 + } + ;; + github-token) + ;; + *) + echo "::error::Unsupported WORKFLOW_SYNC_AUTH_MODE: ${AUTH_MODE}" + exit 1 + ;; + esac + + - name: Create LibreCode GitHub App token + if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == '' || vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} + id: librecode-app-token + 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 + permission-workflows: write + + - name: Create consumer GitHub App token + if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'github-app' }} + id: consumer-app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + 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 }} + permission-contents: write + permission-pull-requests: write + permission-workflows: write + + - name: Resolve workflow sync token + id: auth-token + shell: bash + env: + AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} + LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} + CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + + case "${AUTH_MODE}" in + librecode-app) token="${LIBRECODE_APP_TOKEN}" ;; + github-app) token="${CONSUMER_APP_TOKEN}" ;; + token) token="${CONSUMER_TOKEN}" ;; + github-token) token="${GITHUB_TOKEN}" ;; + *) exit 1 ;; + esac + + [[ -n "${token}" ]] || { + echo "::error::Selected workflow sync authentication produced an empty token" + exit 1 + } + + echo "::add-mask::${token}" + echo "token=${token}" >> "${GITHUB_OUTPUT}" + + - name: Checkout workflow repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + path: source + repository: LibreCodeCoop/.github + + - name: Record workflow catalog revision + id: catalog-revision + working-directory: source + shell: bash + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + - name: Checkout app + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + path: target + ref: ${{ matrix.branches }} + + - name: Synchronize workflow templates + id: sync + uses: ./source/actions/sync-workflows + with: + source: source/workflow-templates + target: target + catalog-commit: ${{ steps.catalog-revision.outputs.sha }} + + - name: Create Pull Request + if: ${{ steps.sync.outputs.changed == 'true' }} + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + token: ${{ steps.auth-token.outputs.token }} + commit-message: 'ci(actions): Update workflow templates from organization template repository' + committer: GitHub + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + path: target + signoff: true + branch: 'automated/noid/${{ matrix.branches }}-update-workflows' + title: '[${{ matrix.branches }}] ci(actions): Update workflow templates from organization template repository' + draft: ${{ steps.sync.outputs.patch_failed == 'true' }} + add-paths: .github/workflows/*.yml,.github/actions-lock.txt + body: | + Automated update of workflow templates from [LibreCodeCoop/.github](https://github.com/LibreCodeCoop/.github) + ${{ steps.sync.outputs.summary }} + labels: | + dependencies + 3. to review diff --git a/.github/workflows/sync-workflow-templates.yml.patch b/.github/workflows/sync-workflow-templates.yml.patch new file mode 100644 index 0000000..a6061ff --- /dev/null +++ b/.github/workflows/sync-workflow-templates.yml.patch @@ -0,0 +1,30 @@ +--- a/.github/workflows/sync-workflow-templates.yml ++++ b/.github/workflows/sync-workflow-templates.yml +@@ -53,12 +53,12 @@ + - name: Validate workflow sync authentication + shell: bash + env: ++ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} +- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} + LIBRECODE_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} + LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} + 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 || secrets.COMMAND_BOT_PAT }} +- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} + run: | + set -euo pipefail + +@@ -119,10 +119,10 @@ + id: auth-token + shell: bash + env: ++ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} +- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} + LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} + CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} ++ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} +- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail From e4b51c4703b2797289d08aec66a718252aa02169 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:26:55 +0000 Subject: [PATCH 06/13] fix(ci): align generated submodule workflow with catalog runner aliases Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/command-submodule-pr.yml | 4 ++-- .github/workflows/command-submodule-pr.yml.patch | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/command-submodule-pr.yml b/.github/workflows/command-submodule-pr.yml index 3d75214..cdebc1d 100644 --- a/.github/workflows/command-submodule-pr.yml +++ b/.github/workflows/command-submodule-pr.yml @@ -11,7 +11,7 @@ permissions: jobs: init: - runs-on: ubuntu-latest-low + runs-on: ubuntu-latest # A consumer patch or repository variable configures the command. if: github.event.issue.pull_request != '' && github.event.comment.body == '/libresign-pr' @@ -71,7 +71,7 @@ jobs: reactions: '-1' process: - runs-on: ubuntu-latest-low + runs-on: ubuntu-latest needs: init env: diff --git a/.github/workflows/command-submodule-pr.yml.patch b/.github/workflows/command-submodule-pr.yml.patch index 20f2f72..f38e25e 100644 --- a/.github/workflows/command-submodule-pr.yml.patch +++ b/.github/workflows/command-submodule-pr.yml.patch @@ -1,7 +1,7 @@ --- a/.github/workflows/command-submodule-pr.yml +++ b/.github/workflows/command-submodule-pr.yml @@ -14,7 +14,7 @@ - runs-on: ubuntu-latest-low + runs-on: ubuntu-latest # A consumer patch or repository variable configures the command. + if: github.event.issue.pull_request != '' && github.event.comment.body == '/libresign-pr' From a1e2e0dd9cfe923469db08d9a17d8e769df00e38 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:39:39 +0000 Subject: [PATCH 07/13] fix(ci): isolate Composer execution from publishing credentials Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/composer-auto.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/composer-auto.yml b/.github/workflows/composer-auto.yml index 808540d..1076e85 100644 --- a/.github/workflows/composer-auto.yml +++ b/.github/workflows/composer-auto.yml @@ -74,7 +74,7 @@ jobs: - name: Checkout ${{ needs.init.outputs.head_ref }} uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - token: ${{ secrets.COMMAND_BOT_PAT }} + persist-credentials: false fetch-depth: 0 ref: ${{ needs.init.outputs.head_ref }} @@ -109,6 +109,7 @@ jobs: - name: Commit and push regenerated dependencies env: HEAD_REF: ${{ needs.init.outputs.head_ref }} + GH_TOKEN: ${{ secrets.COMMAND_BOT_PAT }} # zizmor: ignore[secrets-outside-env] run: | git add -A if git diff --cached --quiet; then @@ -116,6 +117,7 @@ jobs: exit 0 fi git commit --signoff -m 'chore(autoloader): Regenerate scoped dependencies' + gh auth setup-git git push origin "HEAD:$HEAD_REF" - name: Add reaction on failure From a9cf9c692d0fbda0f175b09f2c9e4fc85d72d21a Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:40:13 +0000 Subject: [PATCH 08/13] fix(ci): disable untrusted Git hooks during scoped dependency publication Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/composer-auto.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composer-auto.yml b/.github/workflows/composer-auto.yml index 1076e85..e926950 100644 --- a/.github/workflows/composer-auto.yml +++ b/.github/workflows/composer-auto.yml @@ -116,9 +116,9 @@ jobs: echo 'No regenerated files changed' exit 0 fi - git commit --signoff -m 'chore(autoloader): Regenerate scoped dependencies' + git -c core.hooksPath=/dev/null commit --signoff -m 'chore(autoloader): Regenerate scoped dependencies' gh auth setup-git - git push origin "HEAD:$HEAD_REF" + git -c core.hooksPath=/dev/null push origin "HEAD:$HEAD_REF" - name: Add reaction on failure uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 From c94101be86b103ff2f64b9693ba6241024756949 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:49:31 +0000 Subject: [PATCH 09/13] fix(ci): create LibreCode App token only in explicit app mode Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/sync-workflow-templates.yml | 2 +- .github/workflows/sync-workflow-templates.yml.patch | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml index c95acc9..285fb9f 100644 --- a/.github/workflows/sync-workflow-templates.yml +++ b/.github/workflows/sync-workflow-templates.yml @@ -90,7 +90,7 @@ jobs: esac - name: Create LibreCode GitHub App token - if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == '' || vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} + if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} id: librecode-app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: diff --git a/.github/workflows/sync-workflow-templates.yml.patch b/.github/workflows/sync-workflow-templates.yml.patch index a6061ff..3c084cc 100644 --- a/.github/workflows/sync-workflow-templates.yml.patch +++ b/.github/workflows/sync-workflow-templates.yml.patch @@ -15,6 +15,15 @@ run: | set -euo pipefail +@@ -90,7 +90,7 @@ + esac + + - name: Create LibreCode GitHub App token +- if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == '' || vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} ++ if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} + id: librecode-app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: @@ -119,10 +119,10 @@ id: auth-token shell: bash From 3d59cd5308f90b7afeb6cedff03ca1b6509e3806 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:03:22 +0000 Subject: [PATCH 10/13] ci: consume centralized workflow sync authentication logic Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/sync-workflow-templates.yml | 9 +++--- .../sync-workflow-templates.yml.patch | 32 +++++++------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml index 285fb9f..229c94e 100644 --- a/.github/workflows/sync-workflow-templates.yml +++ b/.github/workflows/sync-workflow-templates.yml @@ -36,6 +36,9 @@ jobs: contents: write pull-requests: write + env: + AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} + steps: - name: Check actor permission if: ${{ github.event_name == 'workflow_dispatch' }} @@ -53,7 +56,6 @@ jobs: - name: Validate workflow sync authentication shell: bash env: - AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} LIBRECODE_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} CONSUMER_APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID }} @@ -90,7 +92,7 @@ jobs: esac - name: Create LibreCode GitHub App token - if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} + if: ${{ env.AUTH_MODE == 'librecode-app' }} id: librecode-app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: @@ -103,7 +105,7 @@ jobs: permission-workflows: write - name: Create consumer GitHub App token - if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'github-app' }} + if: ${{ env.AUTH_MODE == 'github-app' }} id: consumer-app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: @@ -119,7 +121,6 @@ jobs: id: auth-token shell: bash env: - AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} diff --git a/.github/workflows/sync-workflow-templates.yml.patch b/.github/workflows/sync-workflow-templates.yml.patch index 3c084cc..0507038 100644 --- a/.github/workflows/sync-workflow-templates.yml.patch +++ b/.github/workflows/sync-workflow-templates.yml.patch @@ -1,12 +1,15 @@ --- a/.github/workflows/sync-workflow-templates.yml +++ b/.github/workflows/sync-workflow-templates.yml -@@ -53,12 +53,12 @@ - - name: Validate workflow sync authentication - shell: bash - env: -+ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} -- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} - LIBRECODE_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} +@@ -37,7 +37,7 @@ + pull-requests: write + + env: ++ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} +- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} + + steps: + - name: Check actor permission +@@ -60,7 +60,7 @@ LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} CONSUMER_APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID }} CONSUMER_APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} @@ -15,21 +18,8 @@ run: | set -euo pipefail -@@ -90,7 +90,7 @@ - esac - - - name: Create LibreCode GitHub App token -- if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == '' || vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} -+ if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} - id: librecode-app-token - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 - with: -@@ -119,10 +119,10 @@ - id: auth-token - shell: bash +@@ -123,7 +123,7 @@ env: -+ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} -- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} From 6e6737380f426e47d6499831c915e5f9d2f82d42 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:21:44 +0000 Subject: [PATCH 11/13] ci: use provider-neutral shared sync workflow with token-only consumer patch Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/sync-workflow-templates.yml | 84 ++++++++----------- .../sync-workflow-templates.yml.patch | 20 +---- 2 files changed, 36 insertions(+), 68 deletions(-) diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml index 229c94e..a3b7ec8 100644 --- a/.github/workflows/sync-workflow-templates.yml +++ b/.github/workflows/sync-workflow-templates.yml @@ -56,29 +56,30 @@ jobs: - name: Validate workflow sync authentication shell: bash env: - LIBRECODE_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} - LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} - 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 || secrets.COMMAND_BOT_PAT }} + APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID } + APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY } + LEGACY_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID } + LEGACY_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY } + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN } run: | set -euo pipefail - case "${AUTH_MODE}" in - librecode-app) - [[ -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_CLIENT_ID}" && -n "${CONSUMER_APP_PRIVATE_KEY}" ]] || { + case "\${AUTH_MODE}" in + github-app|librecode-app) + if [[ -n "\${APP_CLIENT_ID}" || -n "\${APP_PRIVATE_KEY}" ]]; then + [[ -n "\${APP_CLIENT_ID}" && -n "\${APP_PRIVATE_KEY}" ]] || { + echo "::error::WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY must be configured together" + exit 1 + } + elif [[ -n "\${LEGACY_APP_CLIENT_ID}" && -n "\${LEGACY_APP_PRIVATE_KEY}" ]]; then + echo "::notice::Legacy App credentials are supported for compatibility; migrate to WORKFLOW_SYNC_APP_*" + else echo "::error::github-app requires WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY" exit 1 - } + fi ;; token) - [[ -n "${CONSUMER_TOKEN}" ]] || { + [[ -n "\${CONSUMER_TOKEN}" ]] || { echo "::error::token mode requires WORKFLOW_SYNC_TOKEN" exit 1 } @@ -86,33 +87,20 @@ jobs: github-token) ;; *) - echo "::error::Unsupported WORKFLOW_SYNC_AUTH_MODE: ${AUTH_MODE}" + echo "::error::Unsupported WORKFLOW_SYNC_AUTH_MODE: \${AUTH_MODE}" exit 1 ;; esac - - name: Create LibreCode GitHub App token - if: ${{ env.AUTH_MODE == 'librecode-app' }} - id: librecode-app-token - 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 - permission-workflows: write - - - name: Create consumer GitHub App token - if: ${{ env.AUTH_MODE == 'github-app' }} - id: consumer-app-token + - name: Create GitHub App token + if: ${{ env.AUTH_MODE == 'github-app' || env.AUTH_MODE == 'librecode-app' } + id: workflow-app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: - 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 }} + client-id: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID || vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID } + private-key: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY || secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY } + owner: ${{ github.repository_owner } + repositories: ${{ github.event.repository.name } permission-contents: write permission-pull-requests: write permission-workflows: write @@ -121,28 +109,26 @@ jobs: id: auth-token shell: bash env: - LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} - CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} - CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_APP_TOKEN: ${{ steps.workflow-app-token.outputs.token } + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN } + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN } run: | set -euo pipefail - case "${AUTH_MODE}" in - librecode-app) token="${LIBRECODE_APP_TOKEN}" ;; - github-app) token="${CONSUMER_APP_TOKEN}" ;; - token) token="${CONSUMER_TOKEN}" ;; - github-token) token="${GITHUB_TOKEN}" ;; + case "\${AUTH_MODE}" in + github-app|librecode-app) token="\${WORKFLOW_APP_TOKEN}" ;; + token) token="\${CONSUMER_TOKEN}" ;; + github-token) token="\${GITHUB_TOKEN}" ;; *) exit 1 ;; esac - [[ -n "${token}" ]] || { + [[ -n "\${token}" ]] || { echo "::error::Selected workflow sync authentication produced an empty token" exit 1 } - echo "::add-mask::${token}" - echo "token=${token}" >> "${GITHUB_OUTPUT}" + echo "::add-mask::\${token}" + echo "token=\${token}" >> "\${GITHUB_OUTPUT}" - name: Checkout workflow repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/sync-workflow-templates.yml.patch b/.github/workflows/sync-workflow-templates.yml.patch index 0507038..a1020f2 100644 --- a/.github/workflows/sync-workflow-templates.yml.patch +++ b/.github/workflows/sync-workflow-templates.yml.patch @@ -5,25 +5,7 @@ env: + AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} -- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} +- AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'github-app' }} steps: - name: Check actor permission -@@ -60,7 +60,7 @@ - LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} - 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 || secrets.COMMAND_BOT_PAT }} -- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} - run: | - set -euo pipefail - -@@ -123,7 +123,7 @@ - env: - LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} - CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} -+ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} -- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -euo pipefail From 4d36d0209143bb109616fe1d185c849cb2a2c753 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:22:41 +0000 Subject: [PATCH 12/13] ci: adopt neutral catalog authentication while preserving token mode Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/sync-workflow-templates.yml | 52 +++++++++---------- .../sync-workflow-templates.yml.patch | 18 +++++++ 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml index a3b7ec8..5ffad60 100644 --- a/.github/workflows/sync-workflow-templates.yml +++ b/.github/workflows/sync-workflow-templates.yml @@ -56,22 +56,22 @@ jobs: - name: Validate workflow sync authentication shell: bash env: - APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID } - APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY } - LEGACY_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID } - LEGACY_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY } - CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN } + APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID }} + APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} + LEGACY_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} + LEGACY_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} run: | set -euo pipefail - case "\${AUTH_MODE}" in + case "${AUTH_MODE}" in github-app|librecode-app) - if [[ -n "\${APP_CLIENT_ID}" || -n "\${APP_PRIVATE_KEY}" ]]; then - [[ -n "\${APP_CLIENT_ID}" && -n "\${APP_PRIVATE_KEY}" ]] || { + if [[ -n "${APP_CLIENT_ID}" || -n "${APP_PRIVATE_KEY}" ]]; then + [[ -n "${APP_CLIENT_ID}" && -n "${APP_PRIVATE_KEY}" ]] || { echo "::error::WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY must be configured together" exit 1 } - elif [[ -n "\${LEGACY_APP_CLIENT_ID}" && -n "\${LEGACY_APP_PRIVATE_KEY}" ]]; then + elif [[ -n "${LEGACY_APP_CLIENT_ID}" && -n "${LEGACY_APP_PRIVATE_KEY}" ]]; then echo "::notice::Legacy App credentials are supported for compatibility; migrate to WORKFLOW_SYNC_APP_*" else echo "::error::github-app requires WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY" @@ -79,7 +79,7 @@ jobs: fi ;; token) - [[ -n "\${CONSUMER_TOKEN}" ]] || { + [[ -n "${CONSUMER_TOKEN}" ]] || { echo "::error::token mode requires WORKFLOW_SYNC_TOKEN" exit 1 } @@ -87,20 +87,20 @@ jobs: github-token) ;; *) - echo "::error::Unsupported WORKFLOW_SYNC_AUTH_MODE: \${AUTH_MODE}" + echo "::error::Unsupported WORKFLOW_SYNC_AUTH_MODE: ${AUTH_MODE}" exit 1 ;; esac - name: Create GitHub App token - if: ${{ env.AUTH_MODE == 'github-app' || env.AUTH_MODE == 'librecode-app' } + if: ${{ env.AUTH_MODE == 'github-app' || env.AUTH_MODE == 'librecode-app' }} id: workflow-app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: - client-id: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID || vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID } - private-key: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY || secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY } - owner: ${{ github.repository_owner } - repositories: ${{ github.event.repository.name } + client-id: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID || vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} + private-key: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY || secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: ${{ github.event.repository.name }} permission-contents: write permission-pull-requests: write permission-workflows: write @@ -109,26 +109,26 @@ jobs: id: auth-token shell: bash env: - WORKFLOW_APP_TOKEN: ${{ steps.workflow-app-token.outputs.token } - CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN } - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN } + WORKFLOW_APP_TOKEN: ${{ steps.workflow-app-token.outputs.token }} + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail - case "\${AUTH_MODE}" in - github-app|librecode-app) token="\${WORKFLOW_APP_TOKEN}" ;; - token) token="\${CONSUMER_TOKEN}" ;; - github-token) token="\${GITHUB_TOKEN}" ;; + case "${AUTH_MODE}" in + github-app|librecode-app) token="${WORKFLOW_APP_TOKEN}" ;; + token) token="${CONSUMER_TOKEN}" ;; + github-token) token="${GITHUB_TOKEN}" ;; *) exit 1 ;; esac - [[ -n "\${token}" ]] || { + [[ -n "${token}" ]] || { echo "::error::Selected workflow sync authentication produced an empty token" exit 1 } - echo "::add-mask::\${token}" - echo "token=\${token}" >> "\${GITHUB_OUTPUT}" + echo "::add-mask::${token}" + echo "token=${token}" >> "${GITHUB_OUTPUT}" - name: Checkout workflow repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/sync-workflow-templates.yml.patch b/.github/workflows/sync-workflow-templates.yml.patch index a1020f2..fe77711 100644 --- a/.github/workflows/sync-workflow-templates.yml.patch +++ b/.github/workflows/sync-workflow-templates.yml.patch @@ -9,3 +9,21 @@ steps: - name: Check actor permission +@@ -60,7 +60,7 @@ + APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} + LEGACY_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} + LEGACY_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} ++ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} +- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} + run: | + set -euo pipefail + +@@ -110,7 +110,7 @@ + shell: bash + env: + WORKFLOW_APP_TOKEN: ${{ steps.workflow-app-token.outputs.token }} ++ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} +- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail From c4d8b0ff368c9047a79a66ca6b8fdd153da83596 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:35:54 +0000 Subject: [PATCH 13/13] ci: require explicit generic workflow sync token without compatibility fallback Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .github/workflows/sync-workflow-templates.yml | 27 +++++++------------ .../sync-workflow-templates.yml.patch | 20 +------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/.github/workflows/sync-workflow-templates.yml b/.github/workflows/sync-workflow-templates.yml index 5ffad60..7ec9b92 100644 --- a/.github/workflows/sync-workflow-templates.yml +++ b/.github/workflows/sync-workflow-templates.yml @@ -58,25 +58,16 @@ jobs: env: APP_CLIENT_ID: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID }} APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} - LEGACY_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} - LEGACY_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} - CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} run: | set -euo pipefail case "${AUTH_MODE}" in - github-app|librecode-app) - if [[ -n "${APP_CLIENT_ID}" || -n "${APP_PRIVATE_KEY}" ]]; then - [[ -n "${APP_CLIENT_ID}" && -n "${APP_PRIVATE_KEY}" ]] || { - echo "::error::WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY must be configured together" - exit 1 - } - elif [[ -n "${LEGACY_APP_CLIENT_ID}" && -n "${LEGACY_APP_PRIVATE_KEY}" ]]; then - echo "::notice::Legacy App credentials are supported for compatibility; migrate to WORKFLOW_SYNC_APP_*" - else + github-app) + [[ -n "${APP_CLIENT_ID}" && -n "${APP_PRIVATE_KEY}" ]] || { echo "::error::github-app requires WORKFLOW_SYNC_APP_CLIENT_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY" exit 1 - fi + } ;; token) [[ -n "${CONSUMER_TOKEN}" ]] || { @@ -93,12 +84,12 @@ jobs: esac - name: Create GitHub App token - if: ${{ env.AUTH_MODE == 'github-app' || env.AUTH_MODE == 'librecode-app' }} + if: ${{ env.AUTH_MODE == 'github-app' }} id: workflow-app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: - client-id: ${{ vars.WORKFLOW_SYNC_APP_CLIENT_ID || vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} - private-key: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY || secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} + 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 }} permission-contents: write @@ -110,13 +101,13 @@ jobs: shell: bash env: WORKFLOW_APP_TOKEN: ${{ steps.workflow-app-token.outputs.token }} - CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} + CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail case "${AUTH_MODE}" in - github-app|librecode-app) token="${WORKFLOW_APP_TOKEN}" ;; + github-app) token="${WORKFLOW_APP_TOKEN}" ;; token) token="${CONSUMER_TOKEN}" ;; github-token) token="${GITHUB_TOKEN}" ;; *) exit 1 ;; diff --git a/.github/workflows/sync-workflow-templates.yml.patch b/.github/workflows/sync-workflow-templates.yml.patch index fe77711..b3e0b17 100644 --- a/.github/workflows/sync-workflow-templates.yml.patch +++ b/.github/workflows/sync-workflow-templates.yml.patch @@ -4,26 +4,8 @@ pull-requests: write env: -+ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} - AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'github-app' }} ++ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'token' }} steps: - name: Check actor permission -@@ -60,7 +60,7 @@ - APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} - LEGACY_APP_CLIENT_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_CLIENT_ID }} - LEGACY_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} -+ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} -- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} - run: | - set -euo pipefail - -@@ -110,7 +110,7 @@ - shell: bash - env: - WORKFLOW_APP_TOKEN: ${{ steps.workflow-app-token.outputs.token }} -+ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN || secrets.COMMAND_BOT_PAT }} -- CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -euo pipefail