feat: enable Art4Artist event #415
Workflow file for this run
This file contains 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: 🚀 Deploy PR previews | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- closed | |
paths: | |
- '.github/**' | |
- 'src/**' | |
- '.env' | |
- 'index.html' | |
- 'vite.config.js' | |
concurrency: preview-${{ github.ref }} | |
jobs: | |
check_access: | |
runs-on: ubuntu-latest | |
outputs: | |
level: ${{ steps.access_check.outputs.has-write }} | |
steps: | |
- name: 🗝️ Check PR origin & author write access | |
id: access_check | |
run: | | |
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "teia-community/teia-ui" ]; then | |
echo "Aborting since we the head is ${{ github.event.pull_request.head.repo.full_name }}!" | |
echo "has-write=none" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission" | jq -r .permission) | |
echo "Workflow ran by ${{ github.actor }}" | |
echo "Permissions of ${{ github.event.pull_request.user.login }} (PR author): ${PERMISSION}" | |
echo "has-write=${PERMISSION}" >> $GITHUB_OUTPUT | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy-preview: | |
runs-on: ubuntu-latest | |
needs: check_access | |
if: needs.check_access.outputs.level == 'write' || needs.check_access.outputs.level == 'admin' | |
strategy: | |
matrix: | |
node-version: [18] | |
steps: | |
- name: ⏬ Checkout | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
- name: ⚙️ Install and Build | |
run: | | |
export GH_BASE_URL="/teia-ui/previews/pr-${{ github.event.pull_request.number }}/" | |
npm ci | |
npm run build | |
- name: Deploy preview | |
uses: rossjrw/pr-preview-action@v1 | |
with: | |
source-dir: ./build/ | |
preview-branch: gh-pages | |
umbrella-dir: previews |