Skip to content

Commit

Permalink
chore(ci): add pull request previews
Browse files Browse the repository at this point in the history
Addresses SRGSSR/pillarbox-web#196 by introducing pull request previews using
rossjrw/pr-preview-action. This new workflow enables us to review both visual and functional changes
before merging. Additional workflow updates include:

- The JamesIves/github-pages-deploy-action`+ has been updated from version 3 to version 4. This
  update introduces the following configurations to this action:
  - `force: false`: This disables force push to the deployment branch.
  - `clean-exclude: pr-preview/`: This prevents the deletion of PR previews when the main branch is
    deployed.
  • Loading branch information
jboix committed Feb 20, 2024
1 parent 145626f commit b35a81f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/github-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ jobs:
npm run build
- name: Deploy GitHub Page 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages
folder: dist
force: false
clean-exclude: pr-preview/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: dist
48 changes: 48 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy PR previews

on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed

concurrency: preview-${{ github.ref }}

jobs:
deploy-preview:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
always-auth: true
registry-url: https://npm.pkg.github.com/
scope: '@srgssr'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
if: github.event.action != 'closed'
env:
CI: true
run: |
npm pkg delete scripts.prepare
npm ci
- name: Run build
if: github.event.action != 'closed'
run: |
npm run build
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: dist
preview-branch: gh-pages
umbrella-dir: pr-preview

0 comments on commit b35a81f

Please sign in to comment.