|
1 | 1 | --- |
2 | 2 | name: Staging Deploy |
3 | | -run-name: Publish docs to staging website (for PR) |
| 3 | +run-name: Publish docs to staging website |
4 | 4 |
|
5 | 5 | on: |
6 | 6 | pull_request: |
7 | 7 | branches: [main] |
8 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: staging-deploy-${{ github.event.number }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
9 | 13 | permissions: |
10 | 14 | id-token: write |
11 | 15 | contents: read |
12 | 16 | pull-requests: write |
13 | 17 |
|
| 18 | +env: |
| 19 | + DOCS_PATH: docs |
| 20 | + PREVIEW_PATH: /${{ github.event.repository.name }}/pr/${{ github.event.number }} |
| 21 | + PREVIEW_PATH_NO_AUTOGEN: /${{ github.event.repository.name }}/pr/${{ github.event.number }}-no-autogen |
| 22 | + STAGING_URL: https://staging.overturemaps.org |
| 23 | + SCHEMA_PREVIEW: false # Set to true to only publish Schema reference docs |
| 24 | + AWS_ROLE_ARN: arn:aws:iam::763944545891:role/pages-staging-oidc-overturemaps |
| 25 | + AWS_REGION: us-west-2 |
| 26 | + |
14 | 27 | jobs: |
15 | | - build: |
16 | | - name: Build |
| 28 | + check-fork: |
| 29 | + name: Check fork |
| 30 | + runs-on: ubuntu-slim |
| 31 | + steps: |
| 32 | + - name: Staging deploy is not supported for fork PRs |
| 33 | + if: github.event.pull_request.head.repo.full_name != github.repository |
| 34 | + run: | |
| 35 | + echo "::warning title=Staging deploy not supported for fork PRs::Staging previews are only available for PRs from branches within this repository, not forks. Please open your PR from a branch in OvertureMaps/docs instead." |
| 36 | +
|
| 37 | + build-auto-gen: |
| 38 | + name: Build (auto-gen schema) |
| 39 | + if: github.event.pull_request.head.repo.full_name == github.repository |
17 | 40 | runs-on: ubuntu-latest |
| 41 | + needs: check-fork |
| 42 | + outputs: |
| 43 | + schema-sha: ${{ steps.schema-docs.outputs.schema-sha }} |
| 44 | + schema-ref: ${{ steps.schema-docs.outputs.schema-ref }} |
18 | 45 | steps: |
19 | 46 | - name: Check out the main docs repo repository and build. |
20 | 47 | uses: actions/checkout@v6 |
21 | | - with: |
22 | | - fetch-depth: 0 |
23 | 48 |
|
24 | 49 | - name: Set up Node.js |
25 | 50 | uses: actions/setup-node@v6 |
26 | 51 | with: |
27 | | - node-version: '24' |
| 52 | + node-version-file: 'package.json' |
| 53 | + |
| 54 | + - uses: lowlydba/sustainable-npm@v2 |
28 | 55 |
|
29 | | - - name: Install NPM dependencies |
30 | | - run: npm ci --omit=dev |
| 56 | + - run: npm ci --omit=dev |
| 57 | + |
| 58 | + - name: Generate schema markdown docs |
| 59 | + id: schema-docs |
| 60 | + uses: OvertureMaps/workflows/.github/actions/generate-schema-docs@main |
| 61 | + with: |
| 62 | + output-dir: ${{ github.workspace }}/docs/schema/reference |
| 63 | + schema-ref: 'dev' # Temporary until we feel confident in the generated schema sans human review, then should be 'main' |
31 | 64 |
|
32 | 65 | - name: Build Docusaurus website |
33 | | - env: |
34 | | - DOCUSAURUS_URL: https://staging.overturemaps.org/ |
35 | | - DOCUSAURUS_BASE_URL: /${{ github.event.repository.name }}/pr/${{ github.event.number }}/ |
36 | 66 | run: npm run build |
| 67 | + env: |
| 68 | + DOCUSAURUS_URL: ${{ env.STAGING_URL }}/ |
| 69 | + DOCUSAURUS_BASE_URL: ${{ env.PREVIEW_PATH }}/ |
| 70 | + SCHEMA_PREVIEW: ${{ env.SCHEMA_PREVIEW }} |
37 | 71 |
|
38 | 72 | - name: Upload docs build as an artifact 📦 |
39 | 73 | uses: actions/upload-artifact@v7 |
40 | 74 | with: |
41 | 75 | path: build |
42 | 76 | name: build-artifact |
43 | 77 |
|
| 78 | + build-repo-schema: |
| 79 | + # Branch ruleset set to this job name to require this status check |
| 80 | + name: Build |
| 81 | + if: github.event.pull_request.head.repo.full_name == github.repository |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: check-fork |
| 84 | + steps: |
| 85 | + - name: Check out the main docs repo repository and build. |
| 86 | + uses: actions/checkout@v6 |
| 87 | + |
| 88 | + - name: Set up Node.js |
| 89 | + uses: actions/setup-node@v6 |
| 90 | + with: |
| 91 | + node-version-file: 'package.json' |
| 92 | + |
| 93 | + - uses: lowlydba/sustainable-npm@v2 |
| 94 | + |
| 95 | + - run: npm ci --omit=dev |
| 96 | + |
| 97 | + - name: Build Docusaurus website (using existing /schema/reference files) |
| 98 | + run: npm run build |
| 99 | + env: |
| 100 | + DOCUSAURUS_URL: ${{ env.STAGING_URL }}/ |
| 101 | + DOCUSAURUS_BASE_URL: ${{ env.PREVIEW_PATH_NO_AUTOGEN }}/ |
| 102 | + SCHEMA_PREVIEW: ${{ env.SCHEMA_PREVIEW }} |
| 103 | + |
| 104 | + - name: Upload docs build as an artifact 📦 |
| 105 | + uses: actions/upload-artifact@v7 |
| 106 | + with: |
| 107 | + path: build |
| 108 | + name: build-artifact-no-autogen |
| 109 | + |
44 | 110 | deploy: |
45 | 111 | name: Deploy |
46 | | - runs-on: ubuntu-latest |
47 | | - needs: build |
| 112 | + runs-on: ubuntu-slim |
| 113 | + needs: [check-fork, build-auto-gen, build-repo-schema] |
48 | 114 | environment: |
49 | 115 | name: staging |
50 | | - url: https://staging.overturemaps.org/${{ github.event.repository.name }}/pr/${{ github.event.number }}/index.html |
| 116 | + url: ${{ env.STAGING_URL }}${{ env.PREVIEW_PATH }}/index.html |
51 | 117 |
|
52 | 118 | steps: |
53 | 119 | - name: Configure AWS credentials 🔐 |
54 | 120 | uses: aws-actions/configure-aws-credentials@v6 |
55 | 121 | with: |
56 | | - role-to-assume: arn:aws:iam::763944545891:role/pages-staging-oidc-overturemaps |
57 | | - aws-region: us-west-2 |
| 122 | + role-to-assume: ${{ env.AWS_ROLE_ARN }} |
| 123 | + aws-region: ${{ env.AWS_REGION }} |
58 | 124 |
|
59 | | - - name: Download artifacts 📥 |
| 125 | + - name: Download auto-gen artifact 📥 |
60 | 126 | uses: actions/download-artifact@v8 |
61 | 127 | with: |
62 | 128 | name: build-artifact |
63 | | - path: build |
| 129 | + path: build-autogen |
| 130 | + |
| 131 | + - name: Download repo schema artifact 📥 |
| 132 | + uses: actions/download-artifact@v8 |
| 133 | + with: |
| 134 | + name: build-artifact-no-autogen |
| 135 | + path: build-no-autogen |
64 | 136 |
|
65 | 137 | - name: Copy to S3 |
66 | 138 | run: | |
67 | | - aws s3 sync --delete build s3://overture-managed-staging-usw2/gh-pages/${{ github.event.repository.name }}/pr/${{ github.event.number }}/ |
| 139 | + aws s3 sync --delete --quiet build-autogen s3://overture-managed-staging-usw2/gh-pages${{ env.PREVIEW_PATH }}/ |
| 140 | + aws s3 sync --delete --quiet build-no-autogen s3://overture-managed-staging-usw2/gh-pages${{ env.PREVIEW_PATH_NO_AUTOGEN }}/ |
| 141 | +
|
68 | 142 | - name: Bust the Cache |
69 | | - run: aws cloudfront create-invalidation --distribution-id E1KP2IN0H2RGGT --paths "/${{ github.event.repository.name }}/pr/${{ github.event.number }}/*" |
| 143 | + run: | |
| 144 | + aws cloudfront create-invalidation --distribution-id E1KP2IN0H2RGGT --paths "${{ env.PREVIEW_PATH }}/*" "${{ env.PREVIEW_PATH_NO_AUTOGEN }}/*" |
70 | 145 |
|
71 | | - - name: Get deploy timestamp |
72 | | - id: timestamp |
73 | | - run: echo "time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT |
| 146 | + - name: Gather metadata for PR comment |
| 147 | + id: deploy-metadata |
| 148 | + run: | |
| 149 | + echo "time=$(date -u +'%b %d, %Y %H:%M UTC')" >> $GITHUB_OUTPUT |
| 150 | + echo "short-sha=$(echo '${{ github.event.pull_request.head.sha }}' | cut -c1-7)" >> $GITHUB_OUTPUT |
| 151 | + echo "schema-ref-short=$(echo '${{ needs.build-auto-gen.outputs.schema-ref }}' | sed 's|refs/heads/||;s|refs/tags/||')" >> $GITHUB_OUTPUT |
| 152 | + echo "schema-short-sha=$(echo '${{ needs.build-auto-gen.outputs.schema-sha }}' | cut -c1-7)" >> $GITHUB_OUTPUT |
74 | 153 |
|
75 | 154 | - name: Comment on PR |
76 | | - uses: marocchino/sticky-pull-request-comment@v3 |
| 155 | + uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # v3.0.2 |
77 | 156 | with: |
78 | 157 | message: | |
79 | | - ## 🚀 Overture Maps docs branch preview deployed! |
| 158 | + ## 🗺️ OMF Docs previews are live! |
| 159 | +
|
| 160 | + | | | |
| 161 | + |-------------------------|----------------------------------------------------------------------| |
| 162 | + | 🆕 **Auto-gen schema site (beta)** | ${{ env.STAGING_URL }}${{ env.PREVIEW_PATH }}/index.html | |
| 163 | + | 🗂️ **Auto-gen schema ref** | [${{ steps.deploy-metadata.outputs.schema-ref-short }}@${{ steps.deploy-metadata.outputs.schema-short-sha }}](https://github.com/OvertureMaps/schema/commit/${{ needs.build-auto-gen.outputs.schema-sha }}) | |
| 164 | + | 🌍 **Repo schema site** | ${{ env.STAGING_URL }}${{ env.PREVIEW_PATH_NO_AUTOGEN }}/index.html | |
| 165 | + | 🕐 **Updated** | ${{ steps.deploy-metadata.outputs.time }} | |
| 166 | + | 📝 **Commit** | [${{ steps.deploy-metadata.outputs.short-sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}) | |
80 | 167 |
|
81 | | - You can review your changes at https://staging.overturemaps.org/${{ github.event.repository.name }}/pr/${{ github.event.number }}/index.html |
| 168 | + Auto-gen schema site is now available. This is an early preview of a future workflow where we will automatically generate and publish reference docs for the Overture Maps Format schema with every change to the schema repo. |
| 169 | + The auto-gen schema site may contain incomplete or inaccurate information as we are still refining the generation process, so please compare against the repo schema site and refer to the linked commit for the most up-to-date source of truth. |
82 | 170 |
|
83 | | - --- |
84 | | - <sub>♻️ Last refreshed: ${{ steps.timestamp.outputs.time }}</sub> |
| 171 | + > [!NOTE] |
| 172 | + > ♻️ This preview updates automatically with each push to this PR. |
0 commit comments