Skip to content

Pull Request Preview #47

Pull Request Preview

Pull Request Preview #47

Workflow file for this run

# Downloads the artifacts from GitHub which then begins with reading the pull request details,
# once read - it deploys the wiki for preview and once previewed,
# it finds the required comment and then creates a comment with formatted date.
name: Pull Request Preview
on:
workflow_run:
workflows: ["Build Pull Request"]
types: [completed]
jobs:
preview:
runs-on: ubuntu-22.04
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Download Artifacts
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ github.event.workflow_run.id }}
name: build
path: ./build/
- name: Read Pull Request Details
run: |
echo "PR_NUMBER=$(cat ./build/.pr_number)" >> $GITHUB_ENV
echo "PR_COMMIT_HASH=$(cat ./build/.pr_commit_hash)" >> $GITHUB_ENV
rm ./build/.pr_number ./build/.pr_commit_hash
- name: Deploy Preview
uses: cloudflare/pages-action@v1
with:
accountId: ${{ secrets.CF_ACCOUNT_ID }}
apiToken: ${{ secrets.CF_API_TOKEN }}
projectName: figura-wiki
directory: ./build
branch: pr-${{ env.PR_NUMBER }}
gitHubToken: ${{ secrets.GH_BOT_TOKEN }}
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ env.PR_NUMBER }}
comment-author: figuramcbot
body-includes: "A preview for this pull request is now ready! :tada:"
- name: Format Date
run: echo "NOW=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Leave comment
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GH_BOT_TOKEN }}
issue-number: ${{ env.PR_NUMBER }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
A preview for this pull request is now ready! :tada:
| Name | Details |
| -------------- | ----------------------------------------------------- |
| URL | https://pr-${{ env.PR_NUMBER }}.figura-wiki.pages.dev |
| Latest Commit | ${{ env.PR_COMMIT_HASH }} |
| Last Updated | `${{ env.NOW }} UTC` |
This preview will be automatically updated whenever new changes are added.