|
1 |
| -# Based on example at: https://github.com/marketplace/actions/deploy-to-github-pages |
2 |
| - |
3 | 1 | name: Build and Deploy documentation site
|
| 2 | + |
| 3 | +# This workflow is a customized workflow to deploy docs site to Cloudflare |
| 4 | +# The reason we can no longer use Cloudflare's git integration to deploy docs |
| 5 | +# site anymore is that Cloudflare's git integration would only check out |
| 6 | +# documentation repo, whereas we need to check out both `endojs/endo` and |
| 7 | +# `agoric/agoric-sdk` repo to build the docs site. |
| 8 | + |
4 | 9 | on:
|
5 |
| - push: |
6 |
| - branches: |
| 10 | + # If it's a push to production branch, Cloudflare wrangler will deploy it as a |
| 11 | + # production deployment |
| 12 | + # The production branch for documentation project on Cloudflare is configured |
| 13 | + # to be `main` |
| 14 | + push: |
| 15 | + branches: |
7 | 16 | - main
|
| 17 | + # If it's a push to a non-production branch, Cloudflare wrangler will deploy |
| 18 | + # it as a preview deployment |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - "*" |
| 22 | + |
8 | 23 | jobs:
|
9 | 24 | build-and-deploy:
|
10 | 25 | runs-on: ubuntu-latest
|
11 | 26 | steps:
|
12 | 27 | - name: Checkout
|
13 |
| - |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Checkout Endo |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + repository: endojs/endo |
| 34 | + path: endo |
| 35 | + |
| 36 | + - name: Build Endo docs |
| 37 | + run: | |
| 38 | + cd endo |
| 39 | + yarn install |
| 40 | + yarn docs:markdown-for-agoric-documentation-repo |
| 41 | + |
| 42 | + - name: Move Endo docs into main/reference |
| 43 | + run: mv endo/api-docs main/reference/endo |
| 44 | + |
| 45 | + - name: Checkout agoric-sdk |
| 46 | + uses: actions/checkout@v4 |
14 | 47 | with:
|
15 |
| - persist-credentials: false |
| 48 | + repository: agoric/agoric-sdk |
| 49 | + path: agoric-sdk |
16 | 50 |
|
17 |
| - - name: Install and Build |
| 51 | + - name: Build agoric-sdk docs |
18 | 52 | run: |
|
| 53 | + cd agoric-sdk |
19 | 54 | yarn install
|
20 |
| - yarn docs:build |
| 55 | + yarn build |
| 56 | + yarn docs:markdown-for-agoric-documentation-repo |
| 57 | + |
| 58 | + - name: Move agoric-sdk docs into main/reference |
| 59 | + run: mv agoric-sdk/api-docs main/reference/agoric-sdk |
21 | 60 |
|
22 |
| - - name: Configure SSH |
| 61 | + - name: Build Doc site |
23 | 62 | run: |
|
24 |
| - mkdir -m0700 -p ~/.ssh/ |
25 |
| - echo "$SSH_KEY" > ~/.ssh/staging.key |
26 |
| - chmod 600 ~/.ssh/staging.key |
27 |
| - cat >>~/.ssh/config <<END |
28 |
| - Host staging |
29 |
| - HostName $SSH_HOST |
30 |
| - User $SSH_USER |
31 |
| - IdentityFile ~/.ssh/staging.key |
32 |
| - StrictHostKeyChecking no |
33 |
| - Host staging2 |
34 |
| - HostName $SSH_HOST2 |
35 |
| - User $SSH_USER |
36 |
| - IdentityFile ~/.ssh/staging.key |
37 |
| - StrictHostKeyChecking no |
38 |
| - END |
39 |
| - env: |
40 |
| - SSH_USER: ${{ secrets.STAGING_SSH_USER }} |
41 |
| - SSH_KEY: ${{ secrets.STAGING_SSH_KEY }} |
42 |
| - SSH_HOST: ${{ secrets.STAGING_SSH_HOST }} |
43 |
| - SSH_HOST2: ${{ secrets.STAGING_SSH_HOST2 }} |
44 |
| - |
45 |
| - - name: SSH check out and build (staging) |
46 |
| - run: ssh staging 'cd documentation && git pull && yarn install --frozen-lockfile && yarn docs:build' |
47 |
| - |
48 |
| - - name: SSH check out and build (staging2) |
49 |
| - run: ssh staging2 'cd documentation && git pull && yarn install --frozen-lockfile && yarn docs:build' |
50 |
| - |
51 |
| - - name: Deploy to gh-pages |
52 |
| - |
| 63 | + yarn install |
| 64 | + yarn docs:build-cf |
| 65 | + |
| 66 | + - name: Publish to Cloudflare Pages |
| 67 | + id: publish-to-cloudflare-pages |
| 68 | + uses: cloudflare/wrangler-action@v3 |
| 69 | + with: |
| 70 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 71 | + # Cloudflare account ID is safe to be public |
| 72 | + # Ref: https://github.com/cloudflare/wrangler-legacy/issues/209#issuecomment-541654484 |
| 73 | + accountId: 0c4635effffcd7f36d1b9f0425a4367a |
| 74 | + command: pages deploy --project-name=documentation dist/ |
| 75 | + |
| 76 | + - name: Comment with preview URL |
| 77 | + if: github.event_name == 'pull_request' |
| 78 | + uses: actions/github-script@v7 |
53 | 79 | with:
|
54 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by github: https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret |
55 |
| - BRANCH: gh-pages # The branch the action should deploy to. |
56 |
| - FOLDER: main/.vitepress/dist # The folder the action should deploy |
57 |
| - CLEAN: true # Automatically remove deleted files from the deploy branch |
| 80 | + script: | |
| 81 | + github.rest.issues.createComment({ |
| 82 | + issue_number: context.issue.number, |
| 83 | + owner: context.repo.owner, |
| 84 | + repo: context.repo.repo, |
| 85 | + body: 'Cloudflare Pages Preview URL: ${{ steps.publish-to-cloudflare-pages.outputs.deployment-url }}' |
| 86 | + }) |
0 commit comments