Skip to content

Commit

Permalink
PR Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
andraghetti committed Dec 11, 2024
1 parent da01de4 commit 9ec139d
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/preview-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy Preview

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: write

jobs:
quality:
uses: ./.github/workflows/code-quality.yml

preview:
needs: quality
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9

- name: Install Dependencies
working-directory: frontend
run: pnpm install

- name: Build
working-directory: frontend
env:
NODE_ENV: production
NEXT_PUBLIC_BASE_PATH: /pr-preview/${{ github.event.pull_request.number }}
run: pnpm build

- name: Deploy Preview
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: frontend/out
branch: gh-pages
target-folder: pr-preview/${{ github.event.pull_request.number }}
clean: true

- name: Comment PR
uses: actions/github-script@v6
with:
script: |
const preview_url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-preview/${context.issue.number}/`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `📝 Preview deployment is ready!\nURL: ${preview_url}`
});

0 comments on commit 9ec139d

Please sign in to comment.