feat: add permissions for pull-requests and contents in GitHub Action… #5
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
id-token: write | |
pages: write | |
pull-requests: write | |
contents: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build Package | |
run: pnpm run ci | |
- name: Build Docs | |
run: pnpm build:docs | |
- name: Upload docs to GH Pages Artifact | |
uses: actions/upload-pages-artifact@v3 | |
id: docs | |
with: | |
path: ./docs | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
version: pnpm changeset version | |
publish: pnpm changeset publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
docs: | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.docs.outputs.page_url }} | |
needs: deploy | |
steps: | |
- name: Deploy docs to GitHub Pages 🚀 | |
id: docs | |
uses: actions/deploy-pages@v4 |