This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
Update Get Support link on Search page #1037
This file contains 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: Manage PR comments | |
on: | |
issue_comment: | |
# Only trigger on edits | |
# When Vercel bot comments on a PR for the first time, the build URL is not available | |
# It's only added later with an edit | |
types: edited | |
env: | |
APP_NAME: 📖 Storybook | |
APP_PATH: /storybook/ | |
jobs: | |
update_comment: | |
name: Update Vercel comment | |
# Only run if the one updating the comment was the vercel bot | |
if: ${{ github.event.sender.login == 'vercel[bot]' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get new body | |
id: getBody | |
uses: actions/github-script@v6 | |
with: | |
# Using JS, build a new comment body | |
script: | | |
const body = context.payload.comment.body | |
// Extract the build URL, if it exists | |
const match = body.match(/Preview]\((.*?)\)/) | |
const url = match?.[1] | |
if (!url) { | |
console.log('Couldn\'t get the url from the comment body', { match, body }) | |
return '' | |
} | |
const toAppend = `\$1\n\n[**${process.env.APP_NAME}** ↗︎](${url}${process.env.APP_PATH})` | |
return body.replace(/(vercel\.app\) \| .*? \|)([\s\S]*$)/m, toAppend) | |
result-encoding: string | |
- name: 'Debug: print body result' | |
run: echo "${{ steps.getBody.outputs.result }}" | |
- name: Update comment | |
# If there is an updated body, replace the original comment | |
if: ${{ steps.getBody.outputs.result != '' }} | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
body: ${{ steps.getBody.outputs.result }} | |
reactions: rocket | |
edit-mode: replace | |
# If you ever need to debug the event contents, uncomment this job | |
# summary_debug: | |
# name: Summary debug | |
# runs-on: ubuntu-latest | |
# steps: | |
# - run: | | |
# echo $EVENT >> $GITHUB_STEP_SUMMARY | |
# env: | |
# EVENT: ${{ toJSON(github.event) }} | |
# COMMENT: ${{ toJSON(github.event.comment) }} | |
# SENDER: ${{ toJSON(github.event.sender) }} | |
# LOGIN: ${{ github.event.sender.login }} |