Fix: add pull-requests write permission for release PR comments (#1973) #231
This file contains hidden or 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: Push | |
| on: | |
| push: | |
| branches: [master] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed for git push operations | |
| id-token: write # Required for OIDC trusted publishing | |
| pull-requests: write # Needed to post release comments on PRs | |
| steps: | |
| - uses: actions/checkout@v2 # checkout visx + this commit | |
| with: | |
| # pulls all commits (needed for lerna to correctly release only changed packages) | |
| fetch-depth: '0' | |
| - uses: actions/setup-node@v2 | |
| with: | |
| node-version: '22.21.1' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Get yarn cache directory path | |
| id: yarn-cache-dir-path | |
| run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
| - uses: actions/[email protected] | |
| id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
| with: | |
| path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Install dependencies | |
| run: yarn install --immutable | |
| - name: Build packages | |
| run: yarn build | |
| - name: Generate docs | |
| run: yarn docs:generate | |
| - name: Commit package sizes | |
| if: github.repository_owner == 'airbnb' | |
| # note: `git diff-index --quiet HEAD` | |
| # has exit code 0 if there are changes vs HEAD, else nothing to commit | |
| run: | | |
| yarn build:sizes | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| git add . | |
| git diff-index --quiet HEAD || git commit -m "build(${GITHUB_SHA}): auto-commit package sizes" | |
| git push | |
| - name: Release | |
| if: github.repository_owner == 'airbnb' | |
| # the following configurations are needed for lerna to | |
| # - have git credentials for committing tags | |
| # - use OIDC trusted publishing for npm (no token required) | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| yarn build:release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and deploy gallery | |
| # below we | |
| # - setup git credentials provided via actions/checkout@v2 | |
| # - initialize gh-pages-branch as an orphan branch so we don't build history | |
| # - checkout the current commit and create gh-pages-root-dir/ as a new worktree | |
| # - outside that directory HEAD is detached at $GITHUB_SHA | |
| # - within that directory we are on the gh-pages-branch we just initialized | |
| # *worktree initialization should be in a root dir, otherwise the worktree inherits nested directories | |
| # - build the static next.js site and copy the output into gh-pages-root-dir/ | |
| # - we can't output directly into gh-pages-root-dir/ because next wipes the folder including .git | |
| # - commit the demo site within gh-pages-root-dir/ onto the gh-pages-branch | |
| # - push gh-pages-branch to visx as gh-pages. we overwrite history every time so it must be forced | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| git checkout --orphan gh-pages-branch | |
| git reset --hard | |
| touch .nojekyll | |
| git add .nojekyll | |
| git commit -m "bot(${GITHUB_SHA}): initialize gh-pages branch" | |
| git checkout "$GITHUB_SHA" | |
| git worktree add gh-pages-root-dir gh-pages-branch | |
| cd ./packages/visx-demo/ | |
| yarn build | |
| mv -v out/* ../../gh-pages-root-dir/ | |
| cd ../../gh-pages-root-dir/ | |
| touch CNAME | |
| echo "visx.airbnb.tech" > CNAME | |
| git add . | |
| git commit -m "bot(${GITHUB_SHA}): build gh-pages" | |
| git push -f "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git" HEAD:gh-pages |