Update lunch.json #62
This file contains hidden or 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: Run Cloudflare Pages Preview on Fork PRs | |
on: | |
pull_request_target: | |
types: [opened, synchronize, reopened] | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout PR | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Verify PR is from a fork | |
id: check-fork | |
run: | | |
if [[ "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then | |
echo "PR is not from a fork. Skipping deployment." | |
echo "is_fork=false" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
echo "is_fork=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Setup Node.js | |
if: steps.check-fork.outputs.is_fork == 'true' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install dependencies | |
if: steps.check-fork.outputs.is_fork == 'true' | |
run: npm ci | |
- name: Build | |
if: steps.check-fork.outputs.is_fork == 'true' | |
run: npm run build | |
env: | |
CI: true | |
- name: Deploy to Cloudflare Pages | |
if: steps.check-fork.outputs.is_fork == 'true' | |
id: deploy | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ env.CF_ACCOUNT_ID }} | |
command: pages deploy ./dist --project-name=${{ env.PAGES_PROJECT_NAME }} --branch=pr-${{ github.event.pull_request.number }} | |
env: | |
CF_ACCOUNT_ID: eb09a67d16effcedf18472e3926ce09d | |
PAGES_PROJECT_NAME: shs |