Skip to content

Commit

Permalink
ci: update preview-deployment workflow for better PR handling and cla…
Browse files Browse the repository at this point in the history
…rity
  • Loading branch information
EvanNotFound committed Aug 31, 2024
1 parent e677c97 commit ad8f365
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/preview-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,27 @@ jobs:
preview-deployment:
runs-on: ubuntu-latest
environment:
name: PR Preview
name: ${{ github.event_name == 'pull_request_target' && 'PR Preview' || 'Preview' }}
url: ${{ steps.deploy-to-vercel.outputs.preview-url }}
steps:
- id: script
- name: Determine checkout details
id: checkout-details
uses: actions/github-script@v7
with:
script: |
const isPr = ['pull_request_target'].includes(context.eventName)
core.setOutput('ref', isPr ? context.payload.pull_request.head.ref : context.ref)
core.setOutput('repo', isPr ? context.payload.pull_request.head.repo.full_name : context.repo.full_name)
const isPr = context.eventName === 'pull_request_target'
const ref = isPr ? context.payload.pull_request.head.ref : context.ref
const repo = isPr ? context.payload.pull_request.head.repo.full_name : context.repo.full_name
core.setOutput('ref', ref)
core.setOutput('repo', repo)
- name: Checkout theme repository
uses: actions/checkout@v4
with:
path: 'theme'
ref: ${{ steps.script.outputs.ref }}
repository: ${{ steps.script.outputs.repo }}
ref: ${{ steps.checkout-details.outputs.ref }}
repository: ${{ steps.checkout-details.outputs.repo }}


- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down

0 comments on commit ad8f365

Please sign in to comment.