|
1 | 1 | --- upstream/vendor/nextcloud/sync-workflow-templates.yml |
2 | 2 | +++ workflow-templates/sync-workflow-templates.yml |
3 | | -@@ -1,6 +1,6 @@ |
| 3 | +@@ -1,13 +1,19 @@ |
4 | 4 | # This workflow is provided via the organization template repository |
5 | 5 | # |
6 | 6 | -# https://github.com/nextcloud/.github |
7 | 7 | +# https://github.com/LibreCodeCoop/.github |
8 | 8 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization |
9 | 9 | # |
10 | 10 | # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
11 | | -@@ -26,9 +26,6 @@ |
| 11 | + # SPDX-License-Identifier: MIT |
| 12 | + |
| 13 | +-# This workflow will update all workflow templates |
| 14 | +-# Additionally it will reapply `workflow.yml.patch` files after syncing and only then commit the result |
| 15 | ++# This workflow will update all workflow templates. |
| 16 | ++# Additionally it will reapply workflow.yml.patch files after syncing and only then commit the result. |
| 17 | ++# |
| 18 | ++# Authentication is explicit through vars.WORKFLOW_SYNC_AUTH_MODE: |
| 19 | ++# - librecode-app (default): LibreCode-managed GitHub App credentials |
| 20 | ++# - github-app: consumer-owned GitHub App credentials |
| 21 | ++# - token: consumer-owned repository-scoped token |
| 22 | ++# - github-token: built-in GITHUB_TOKEN (generated PRs do not trigger normal PR workflows) |
| 23 | + name: Update workflows |
| 24 | + on: |
| 25 | + workflow_dispatch: |
| 26 | +@@ -26,9 +32,6 @@ |
12 | 27 | matrix: |
13 | 28 | branches: |
14 | 29 | - ${{ github.event.repository.default_branch }} |
|
18 | 33 |
|
19 | 34 | name: Update workflows in ${{ matrix.branches }} |
20 | 35 |
|
21 | | -@@ -42,12 +39,24 @@ |
| 36 | +@@ -42,12 +45,105 @@ |
22 | 37 | with: |
23 | 38 | require: admin |
24 | 39 |
|
25 | | -+ - name: Create GitHub App token |
26 | | -+ id: app-token |
| 40 | ++ - name: Validate workflow sync authentication |
| 41 | ++ shell: bash |
| 42 | ++ env: |
| 43 | ++ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} |
| 44 | ++ LIBRECODE_APP_ID: ${{ vars.LIBRECODE_WORKFLOW_APP_ID }} |
| 45 | ++ LIBRECODE_APP_PRIVATE_KEY: ${{ secrets.LIBRECODE_WORKFLOW_APP_PRIVATE_KEY }} |
| 46 | ++ CONSUMER_APP_ID: ${{ vars.WORKFLOW_SYNC_APP_ID }} |
| 47 | ++ CONSUMER_APP_PRIVATE_KEY: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} |
| 48 | ++ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} |
| 49 | ++ run: | |
| 50 | ++ set -euo pipefail |
| 51 | ++ |
| 52 | ++ case "${AUTH_MODE}" in |
| 53 | ++ librecode-app) |
| 54 | ++ [[ -n "${LIBRECODE_APP_ID}" && -n "${LIBRECODE_APP_PRIVATE_KEY}" ]] || { |
| 55 | ++ echo "::error::librecode-app requires LIBRECODE_WORKFLOW_APP_ID and LIBRECODE_WORKFLOW_APP_PRIVATE_KEY" |
| 56 | ++ exit 1 |
| 57 | ++ } |
| 58 | ++ ;; |
| 59 | ++ github-app) |
| 60 | ++ [[ -n "${CONSUMER_APP_ID}" && -n "${CONSUMER_APP_PRIVATE_KEY}" ]] || { |
| 61 | ++ echo "::error::github-app requires WORKFLOW_SYNC_APP_ID and WORKFLOW_SYNC_APP_PRIVATE_KEY" |
| 62 | ++ exit 1 |
| 63 | ++ } |
| 64 | ++ ;; |
| 65 | ++ token) |
| 66 | ++ [[ -n "${CONSUMER_TOKEN}" ]] || { |
| 67 | ++ echo "::error::token mode requires WORKFLOW_SYNC_TOKEN" |
| 68 | ++ exit 1 |
| 69 | ++ } |
| 70 | ++ ;; |
| 71 | ++ github-token) |
| 72 | ++ ;; |
| 73 | ++ *) |
| 74 | ++ echo "::error::Unsupported WORKFLOW_SYNC_AUTH_MODE: ${AUTH_MODE}" |
| 75 | ++ exit 1 |
| 76 | ++ ;; |
| 77 | ++ esac |
| 78 | ++ |
| 79 | ++ - name: Create LibreCode GitHub App token |
| 80 | ++ if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == '' || vars.WORKFLOW_SYNC_AUTH_MODE == 'librecode-app' }} |
| 81 | ++ id: librecode-app-token |
27 | 82 | + uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 |
28 | 83 | + with: |
29 | 84 | + app-id: ${{ vars.LIBRECODE_WORKFLOW_APP_ID }} |
|
33 | 88 | + permission-contents: write |
34 | 89 | + permission-pull-requests: write |
35 | 90 | + permission-workflows: write |
| 91 | ++ |
| 92 | ++ - name: Create consumer GitHub App token |
| 93 | ++ if: ${{ vars.WORKFLOW_SYNC_AUTH_MODE == 'github-app' }} |
| 94 | ++ id: consumer-app-token |
| 95 | ++ uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 |
| 96 | ++ with: |
| 97 | ++ app-id: ${{ vars.WORKFLOW_SYNC_APP_ID }} |
| 98 | ++ private-key: ${{ secrets.WORKFLOW_SYNC_APP_PRIVATE_KEY }} |
| 99 | ++ owner: ${{ github.repository_owner }} |
| 100 | ++ repositories: ${{ github.event.repository.name }} |
| 101 | ++ permission-contents: write |
| 102 | ++ permission-pull-requests: write |
| 103 | ++ permission-workflows: write |
| 104 | ++ |
| 105 | ++ - name: Resolve workflow sync token |
| 106 | ++ id: auth-token |
| 107 | ++ shell: bash |
| 108 | ++ env: |
| 109 | ++ AUTH_MODE: ${{ vars.WORKFLOW_SYNC_AUTH_MODE || 'librecode-app' }} |
| 110 | ++ LIBRECODE_APP_TOKEN: ${{ steps.librecode-app-token.outputs.token }} |
| 111 | ++ CONSUMER_APP_TOKEN: ${{ steps.consumer-app-token.outputs.token }} |
| 112 | ++ CONSUMER_TOKEN: ${{ secrets.WORKFLOW_SYNC_TOKEN }} |
| 113 | ++ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 114 | ++ run: | |
| 115 | ++ set -euo pipefail |
| 116 | ++ |
| 117 | ++ case "${AUTH_MODE}" in |
| 118 | ++ librecode-app) token="${LIBRECODE_APP_TOKEN}" ;; |
| 119 | ++ github-app) token="${CONSUMER_APP_TOKEN}" ;; |
| 120 | ++ token) token="${CONSUMER_TOKEN}" ;; |
| 121 | ++ github-token) token="${GITHUB_TOKEN}" ;; |
| 122 | ++ *) exit 1 ;; |
| 123 | ++ esac |
| 124 | ++ |
| 125 | ++ [[ -n "${token}" ]] || { |
| 126 | ++ echo "::error::Selected workflow sync authentication produced an empty token" |
| 127 | ++ exit 1 |
| 128 | ++ } |
| 129 | ++ |
| 130 | ++ echo "::add-mask::${token}" |
| 131 | ++ echo "token=${token}" >> "${GITHUB_OUTPUT}" |
36 | 132 | + |
37 | 133 | - name: Checkout workflow repository |
38 | 134 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
|
44 | 140 |
|
45 | 141 | - name: Checkout app |
46 | 142 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
47 | | -@@ -56,86 +65,30 @@ |
| 143 | +@@ -56,86 +152,30 @@ |
48 | 144 | path: target |
49 | 145 | ref: ${{ matrix.branches }} |
50 | 146 |
|
|
123 | 219 | uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 |
124 | 220 | with: |
125 | 221 | - token: ${{ secrets.COMMAND_BOT_WORKFLOWS }} |
126 | | -+ token: ${{ steps.app-token.outputs.token }} |
| 222 | ++ token: ${{ steps.auth-token.outputs.token }} |
127 | 223 | commit-message: 'ci(actions): Update workflow templates from organization template repository' |
128 | 224 | committer: GitHub <noreply@github.com> |
129 | 225 | - author: nextcloud-command <nextcloud-command@users.noreply.github.com> |
130 | | -+ author: librecode-workflow-automation[bot] <331658022+librecode-workflow-automation[bot]@users.noreply.github.com> |
| 226 | ++ author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
131 | 227 | path: target |
132 | 228 | signoff: true |
133 | 229 | branch: 'automated/noid/${{ matrix.branches }}-update-workflows' |
|
138 | 234 | body: | |
139 | 235 | - Automated update of all workflow templates from [nextcloud/.github](https://github.com/nextcloud/.github) |
140 | 236 | - ${{ env.SUMMARY }} |
141 | | -+ Automated update of all workflow templates from [LibreCodeCoop/.github](https://github.com/LibreCodeCoop/.github) |
| 237 | ++ Automated update of workflow templates from [LibreCodeCoop/.github](https://github.com/LibreCodeCoop/.github) |
142 | 238 | + ${{ steps.sync.outputs.summary }} |
143 | 239 | labels: | |
144 | 240 | dependencies |
|
0 commit comments