Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Safely call create-or-update-comment when dealing with forks (#997)

sarayourfriendd42a4ca773d8
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index e8d86c071..e1c538fa3 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -552,20 +552,37 @@ jobs:
})
console.log('Deleted comment with ID ${{ steps.test-results-comment.outputs.comment-id }}')
- - uses: peter-evans/create-or-update-comment@v2
+ - name: Build help body
if: needs.playwright.result == 'failure'
- with:
- issue-number: ${{ github.event.pull_request.number }}
- body: |
- **Playwright failure test results**
+ id: help-body
+ run: |
+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) # Security hardening: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections
+ MESSAGE=$(cat <<HEREDOC
+ help_body<<$EOF
+ **Playwright failure test results**: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}>
- It looks like some of the Playwright tests failed. You can download the Playwright trace
- output for all playwright tests that have failed at the bottom of this page, under the
- "Artifacts" section:
+ It looks like some of the Playwright tests failed. You can download the trace output and image diffs for the failed tests under the "Artifacts" section in the above page.
- <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}>
+ You can read the [docs on how to use this artifact](https://github.com/${{ github.repository }}/blob/main/frontend/test/playwright/README.md#debugging).
+ $EOF
+ HEREDOC
+ )
+ echo "$MESSAGE"
+ echo "$MESSAGE" >> "$GITHUB_OUTPUT"
- Read more about how to use this artifact here: <https://github.com/${{ github.repository }}/blob/main/frontend/test/playwright/README.md#debugging>
+ - uses: peter-evans/create-or-update-comment@v2
+ id: create-comment
+ # Do not leave a comment on forks
+ if: |
+ needs.playwright.result == 'failure' &&
+ (
+ github.event_name == 'pull_request' &&
+ github.event.pull_request.head.repo.owner.login == 'WordPress' &&
+ github.actor != 'dependabot[bot]'
+ )
+ with:
+ issue-number: ${{ github.event.pull_request.number }}
+ body: ${{ steps.help-body.outputs.help_body }}
#################
# Documentation #