WIP: Move to docusaurus #62
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
# This workflow always runs from the state on `master`. | |
# If you want to test changes to the workflow, you need to open a second PR against the branch of the PR with the workflow changes. | |
# This is a security feature so one cannot meddle with secrets. | |
name: Publish preview on CF Pages | |
on: | |
pull_request_target: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
issues: write | |
pull-requests: write | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Build site | |
run: npm build | |
working-directory: ./probe-rs | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
- name: Deploy to CF Pages | |
id: deploy-preview | |
uses: cloudflare/wrangler-action@v3 | |
working-directory: ./probe-rs | |
env: | |
API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
with: | |
apiToken: ${{ env.API_TOKEN }} | |
accountId: ${{ env.ACCOUNT_ID }} | |
command: pages deploy target --project-name=${{ github.event.repository.name }} --branch=${{ env.BRANCH_NAME }} | |
- name: Report preview environment in PR | |
uses: actions/github-script@v6 | |
working-directory: ./probe-rs | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
with: | |
github-token: ${{ secrets.GH_PAT }} | |
script: | | |
let comments = await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
let previousComment = comments.data.find((i) => i.user.login === "probe-rs-bot"); | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '# [Preview](https://${{ env.BRANCH_NAME }}.webpage-5t5.pages.dev/)' | |
}) | |