Skip to content

Commit

Permalink
Update pr preview workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeckem committed Sep 7, 2024
1 parent 159e739 commit 0786b16
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/preview-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Preview PR
on:
pull_request:
pull_request_target:
types:
- opened
- closed
Expand Down Expand Up @@ -32,13 +32,23 @@ jobs:
concurrency: preview-${{ github.ref }}
timeout-minutes: 5
needs: wait
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download latest build artifact
run: |
WORKFLOW_RUN=$(gh run list -c ${{ github.event.pull_request.head.sha }} -w "test-and-build.yml" -e push --json databaseId --limit 1 | jq .[0].databaseId -r)
# Use build result of latest push for local branches
WORKFLOW_EVENT=
if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]]; then
WORKFLOW_EVENT="pull_request"
else
WORKFLOW_EVENT="push"
fi
WORKFLOW_RUN=$(gh run list -c ${{ github.event.pull_request.head.sha }} -w "test-and-build.yml" -e $WORKFLOW_EVENT --json databaseId --limit 1 | jq .[0].databaseId -r)
echo "Latest workflow run: $WORKFLOW_RUN"
mkdir site && cd site;
Expand All @@ -47,10 +57,13 @@ jobs:
gh run download $WORKFLOW_RUN -n build
echo "Download successful:"
ls -alh
env:
env:
GH_TOKEN: ${{ github.token }}

- name: Deploy PR Preview
uses: rossjrw/[email protected]
with:
source-dir: ./site/www/
umbrella-dir: "core-packages/pr-previews"
deploy-repository: open-pioneer/trails-pr-previews
token: ${{ secrets.DEPLOY_TOKEN }}

0 comments on commit 0786b16

Please sign in to comment.