Skip to content

Commit

Permalink
Merge pull request #11 from adamviktora/pr-preview
Browse files Browse the repository at this point in the history
feat: add PR preview workflow
  • Loading branch information
adamviktora authored Oct 7, 2024
2 parents e6d2afd + 74a1ac0 commit a6ecae0
Show file tree
Hide file tree
Showing 3 changed files with 483 additions and 26 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: pr-preview
on:
pull_request_target:
jobs:
build-upload:
runs-on: ubuntu-latest
env:
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
GH_PR_NUM: ${{ github.event.number }}
steps:
- name: Check out project from PR branch
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
# Checkout the merge commit so that we can access the PR's changes.
# This is nessesary because `pull_request_target` checks out the base branch (e.g. `main`) by default.
ref: refs/pull/${{ env.GH_PR_NUM }}/head

- name: Check out project
if: github.event_name != 'pull_request_target'
uses: actions/checkout@v4

# Setup and build project
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/cache@v4
id: npm-cache
name: Load npm deps from cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: yarn build
name: Build AI infra ui components
- uses: actions/cache@v4
id: docs-cache
name: Load webpack cache
with:
path: '.cache'
key: ${{ runner.os }}-v4-${{ hashFiles('yarn.lock') }}

- run: yarn build:docs
name: Build docs
- run: node .github/upload-preview.js packages/module/public
name: Upload docs
if: always()
- run: yarn serve:docs & yarn test:a11y
name: a11y tests
- run: node .github/upload-preview.js packages/module/coverage
name: Upload a11y report
if: always()
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/dom": "^10.4.0",
"jest-environment-jsdom": "^29.7.0",
"serve": "^14.2.3"
"serve": "^14.2.3",
"surge": "^0.24.6"
},
"packageManager": "yarn@1.22.22"
}
Loading

0 comments on commit a6ecae0

Please sign in to comment.