Bump sanitize-html and gatsby-transformer-remark #139
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: Comment with Vercel Deploy URLs of changed pages | |
on: | |
pull_request: | |
jobs: | |
post-comment-with-links-to-changed-pages: | |
name: Create or Update | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get list of changed files | |
id: files | |
uses: Ana06/[email protected] # it's a fork of jitterbit/get-changed-files@v1 which works better with pull requests | |
- name: List Vercel Deploy URLs | |
id: links | |
# Note that this uses `%0A` instead of `\n` because of https://github.com/peter-evans/create-or-update-comment#setting-the-comment-body-from-a-file which I could not get to work here - but this brute force method does. | |
run: | | |
body="This PR changes the following pages (Vercel Preview Deploy links):%0A%0A" | |
no_changed_pages="%0A- This PR does not change any pages the [GH Actions workflow](https://github.com/prisma/dataguide/blob/main/.github/workflows/list-changed-pages.yml) could detect." | |
vercelLinks="Changed Vercel links" | |
body="$body%0A%0A$vercelLinks" | |
for changed_file in ${{ steps.files.outputs.all }}; do | |
if [[ $changed_file == content/* ]] | |
then | |
no_changed_pages="" | |
cleaned_file=$(echo "$changed_file" | sed -E 's:content/:/:g' | sed -E 's:/index.mdx::g' | sed -e 's/.mdx//g' | sed -E 's:/[0-9]+-:/:g' ) | |
# TODO special case for images and similar non .mdx files | |
normalized_ref=$(echo "${{github.event.pull_request.head.ref}}" | sed -E 's:_::g') | |
# Output inside the action | |
echo "- https://dataguide-git-${normalized_ref}-prisma.vercel.app$cleaned_file" | |
# Also collect into string | |
linksVercel="%0A- [/dataguide$cleaned_file](https://dataguide-git-${normalized_ref}-prisma.vercel.app$cleaned_file) ([currently](https://prisma.io/dataguide$cleaned_file))" | |
body="$body$linksVercel" | |
fi | |
done | |
body="$body$no_changed_pages" | |
body="$body%0A%0A(Note that links will only be valid after Vercel preview deploy succeeded)" | |
echo "::set-output name=body::$body" | |
- name: Find existing comment | |
uses: peter-evans/find-comment@v1 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: following pages | |
- name: Create comment | |
if: steps.fc.outputs.comment-id == '' | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: ${{ steps.links.outputs.body }} | |
- name: Update comment | |
if: steps.fc.outputs.comment-id != '' | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
body: ${{ steps.links.outputs.body }} | |
edit-mode: replace |