name: build & deploy on: push: branches: [source] pull_request: workflow_dispatch: permissions: contents: read # Let a running deploy finish rather than cancelling it half way. concurrency: group: deploy cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version-file: .node-version cache: npm - run: npm ci - run: npm run build # Uploaded on pull requests too, so the built site can be downloaded # from the run page for review. - uses: actions/upload-artifact@v7 with: name: site path: build # nodejs.jp is served by Netlify out of the master branch, so publishing # means committing the build output there. This mirrors the update.sh that # CircleCI used to run. deploy: needs: build if: github.event_name != 'pull_request' runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version-file: .node-version cache: npm - run: npm ci - name: Check out master as the build destination run: | git clone --depth 1 -b master \ "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \ build - run: npm run build - name: Commit and push working-directory: build run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' git add -A if git diff --cached --quiet; then echo 'nothing to publish' exit 0 fi git commit -m 'chore(site): automated update from github actions' git push origin HEAD:master