|
| 1 | +#################### 🚧 WARNING: READ THIS BEFORE USING THIS FILE 🚧 #################### |
| 2 | +# |
| 3 | +# |
| 4 | +# |
| 5 | +# IF YOU DON'T KNOW WHAT YOU'RE DOING, YOU CAN EASILY LEAK SECRETS BY USING A |
| 6 | +# `pull_request_target` WORKFLOW INSTEAD OF `pull_request`! SERIOUSLY, DO NOT |
| 7 | +# BLINDLY COPY AND PASTE THIS FILE WITHOUT UNDERSTANDING THE FULL IMPLICATIONS |
| 8 | +# OF WHAT YOU'RE DOING! WE HAVE TESTED THIS FOR OUR OWN USE CASES, WHICH ARE |
| 9 | +# NOT NECESSARILY THE SAME AS YOURS! WHILE WE AREN'T EXPOSING ANY OF OUR SECRETS, |
| 10 | +# ONE COULD EASILY DO SO BY MODIFYING OR ADDING A STEP TO THIS WORKFLOW! |
| 11 | +# |
| 12 | +# |
| 13 | +# |
| 14 | +#################### 🚧 WARNING: READ THIS BEFORE USING THIS FILE 🚧 #################### |
| 15 | + |
| 16 | +name: Docs - Preview Deployment |
| 17 | +on: |
| 18 | + pull_request_target: |
| 19 | + paths: |
| 20 | + - sites/docs/** |
| 21 | + - packages/paneforge/** |
| 22 | + |
| 23 | +# cancel in-progress runs on new commits to same PR (github.event.number) |
| 24 | +concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.event.number || github.sha }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +jobs: |
| 29 | + deploy-preview: |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + pull-requests: write |
| 33 | + deployments: write |
| 34 | + runs-on: ubuntu-latest |
| 35 | + name: Deploy Preview to Cloudflare Pages (admin) |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v3 |
| 38 | + with: |
| 39 | + ref: ${{ github.event.pull_request.head.ref }} |
| 40 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 41 | + - uses: pnpm/action-setup@v2 |
| 42 | + with: |
| 43 | + version: 8 |
| 44 | + - uses: actions/setup-node@v3 |
| 45 | + with: |
| 46 | + node-version: 20 |
| 47 | + |
| 48 | + # PNPM Store cache setup |
| 49 | + - name: Get pnpm store directory |
| 50 | + id: pnpm-cache |
| 51 | + run: | |
| 52 | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 53 | + - name: Setup pnpm cache |
| 54 | + uses: actions/cache@v3 |
| 55 | + with: |
| 56 | + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} |
| 57 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-pnpm-store- |
| 60 | +
|
| 61 | + - name: Install dependencies |
| 62 | + run: pnpm install |
| 63 | + |
| 64 | + - name: Build site |
| 65 | + run: pnpm build |
| 66 | + |
| 67 | + - name: Deploy to Cloudflare Pages |
| 68 | + id: cloudflare-pages-deploy |
| 69 | + uses: AdrianGonz97/refined-cf-pages-action@v1 |
| 70 | + with: |
| 71 | + apiToken: ${{ secrets.CF_API_TOKEN }} |
| 72 | + accountId: ${{ secrets.CF_ACCOUNT_ID }} |
| 73 | + githubToken: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + projectName: paneforge |
| 75 | + directory: ./.svelte-kit/cloudflare |
| 76 | + workingDirectory: sites/docs |
| 77 | + deploymentName: Preview |
0 commit comments