feat: add support for xyz link updates via jsonform #227
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Preview | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| comment: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Comment on PR | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 | |
| with: | |
| script: | | |
| const prNumber = context.issue.number; | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const previewUrl = `https://eodash.github.io/preview-instance/?stacEndpoint=https://catgen.hub-otc.eox.at/ESA-eodashboards/${repo}/pull/${prNumber}/catalog.json`; | |
| const body = `## PR Preview 🚀\n\n[Preview Link](${previewUrl})`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner, | |
| repo, | |
| issue_number: prNumber, | |
| }); | |
| let botComment = null; | |
| for (const comment of comments) { | |
| if (comment.user.type === 'Bot') { | |
| if (comment.body.includes('## PR Preview 🚀')) { | |
| botComment = comment; | |
| } else if (comment.body.toLowerCase().includes('preview')) { | |
| console.log(`Deleting old preview comment: ${comment.id}`); | |
| await github.rest.issues.deleteComment({ | |
| owner, | |
| repo, | |
| comment_id: comment.id, | |
| }); | |
| } | |
| } | |
| } | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner, | |
| repo, | |
| comment_id: botComment.id, | |
| body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: prNumber, | |
| body | |
| }); | |
| } |