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
35 changes: 31 additions & 4 deletions patches/nextcloud/command-submodule-pr.yml.patch
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
persist-credentials: false
fetch-depth: 0
ref: ${{ needs.init.outputs.head_sha }}
@@ -99,63 +133,126 @@
@@ -99,63 +133,153 @@
coverage: none

- name: Generate composer diff
Expand Down Expand Up @@ -244,10 +244,9 @@
+ signoff: true
+ sign-commits: true
+
+ - name: Verify signed destination and report source
+ - name: Verify signed destination
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ TARGET_URL: ${{ steps.target-pr.outputs.pull-request-url }}
+ VERIFIED: ${{ steps.target-pr.outputs.pull-request-commits-verified }}
+ run: |
Expand All @@ -256,8 +255,36 @@
+ echo "::error::Destination pull request commits were not verified"
+ exit 1
+ }
+ [[ -n "$TARGET_URL" ]] || exit 1
+ [[ -n "$TARGET_URL" ]] || {
+ echo "::error::Signed destination pull request URL is missing"
+ exit 1
+ }
+
+ - name: Create scoped source feedback token
+ id: source-feedback-token
+ continue-on-error: true
+ 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-issues: write
+
+ - name: Report linked PR on source
+ if: steps.source-feedback-token.outputs.token != ''
+ continue-on-error: true
+ shell: bash
+ env:
+ GH_TOKEN: ${{ steps.source-feedback-token.outputs.token }}
+ TARGET_URL: ${{ steps.target-pr.outputs.pull-request-url }}
+ run: |
+ set -euo pipefail
+ gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" -f body="- Parent PR: $TARGET_URL"
+
+ - name: Warn if source feedback is unavailable
+ if: steps.source-feedback-token.outputs.token == ''
+ run: echo "::warning::Source feedback token unavailable; the verified destination pull request was created."

- name: Add reaction on failure
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
Expand Down
5 changes: 5 additions & 0 deletions tests/test_submodule_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def test_commands_use_scoped_temporary_tokens(self) -> None:
source = (ROOT / "workflow-templates/command-submodule-pr.yml").read_text()
self.assertNotIn("COMMAND_BOT_PAT", source)
self.assertIn("issues: write", source)
self.assertIn("id: source-feedback-token", source)
self.assertIn("permission-issues: write", source)
self.assertIn("GH_TOKEN: " + "$" + "{{ steps.source-feedback-token.outputs.token }}", source)
self.assertLess(source.index("- name: Verify signed destination"),
source.index("- name: Create scoped source feedback token"))
self.assertIn('gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments"', source)
self.assertNotIn("gh pr comment", source)
self.assertIn("token: " + "$" + "{{ github.token }}", source)
Expand Down
33 changes: 30 additions & 3 deletions workflow-templates/command-submodule-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,9 @@ jobs:
signoff: true
sign-commits: true

- name: Verify signed destination and report source
- name: Verify signed destination
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TARGET_URL: ${{ steps.target-pr.outputs.pull-request-url }}
VERIFIED: ${{ steps.target-pr.outputs.pull-request-commits-verified }}
run: |
Expand All @@ -245,9 +244,37 @@ jobs:
echo "::error::Destination pull request commits were not verified"
exit 1
}
[[ -n "$TARGET_URL" ]] || exit 1
[[ -n "$TARGET_URL" ]] || {
echo "::error::Signed destination pull request URL is missing"
exit 1
}

- name: Create scoped source feedback token
id: source-feedback-token
continue-on-error: true
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-issues: write

- name: Report linked PR on source
if: steps.source-feedback-token.outputs.token != ''
continue-on-error: true
shell: bash
env:
GH_TOKEN: ${{ steps.source-feedback-token.outputs.token }}
TARGET_URL: ${{ steps.target-pr.outputs.pull-request-url }}
run: |
set -euo pipefail
gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" -f body="- Parent PR: $TARGET_URL"

- name: Warn if source feedback is unavailable
if: steps.source-feedback-token.outputs.token == ''
run: echo "::warning::Source feedback token unavailable; the verified destination pull request was created."

- name: Add reaction on failure
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
if: failure()
Expand Down