Let WS and HTTP use the same JSON encoder #3913
Workflow file for this run
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: 🆗 Ok to preview | |
on: | |
pull_request_target: | |
types: [labeled] | |
jobs: | |
ok-to-preview: | |
if: ${{ github.event.label.name == 'ok-to-preview' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get changed files | |
#uses: lots0logs/[email protected] | |
uses: Mineflash07/gh-action-get-changed-files@feature/support-pr-target-event # Remove as soon as PR is merged | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get comment message | |
id: get-comment-message | |
run: | | |
import os, json, textwrap | |
all_files_path = os.path.join(os.environ["HOME"], "files.json") | |
event_json_path = os.environ["GITHUB_EVENT_PATH"] | |
with open(all_files_path) as f: | |
all_files = json.load(f) | |
with open(event_json_path) as f: | |
event_data = json.load(f) | |
links = [ | |
"https://strawberry.rocks/docs/pr/{pr_number}/{path}".format( | |
pr_number=event_data["number"], | |
path=file.replace(".md", "").replace("docs/", "") | |
) | |
for file in all_files | |
if file.startswith("docs/") and file.endswith(".md") | |
] | |
message = textwrap.dedent( | |
""" | |
Hi 👋 You can find a preview of the docs here: | |
{links} | |
""" | |
).format(links="\n".join(links)) | |
message = message.replace("%", "%25").replace("\n", "%0A").replace("\r", "%0D") | |
output = "::set-output name=message::{}".format(message) | |
print(output) | |
shell: python | |
- name: Create comment | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ github.event.number }} | |
body: ${{ steps.get-comment-message.outputs.message }} |