|
| 1 | +name: Docs Preview (Netlify) |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'docs/**' |
| 7 | + |
| 8 | +jobs: |
| 9 | + preview: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout community PR |
| 14 | + uses: actions/checkout@v5 |
| 15 | + |
| 16 | + - name: Checkout website repo |
| 17 | + uses: actions/checkout@v5 |
| 18 | + with: |
| 19 | + repository: asyncapi/website |
| 20 | + path: website |
| 21 | + fetch-depth: 1 |
| 22 | + |
| 23 | + - name: Sync docs into website |
| 24 | + run: | |
| 25 | + rm -rf website/markdown/docs/community/* |
| 26 | + cp -R docs/* website/markdown/docs/community/ |
| 27 | + rm website/markdown/docs/community/README.md |
| 28 | +
|
| 29 | + - name: Setup Node |
| 30 | + uses: actions/setup-node@v6 |
| 31 | + with: |
| 32 | + node-version: '20' |
| 33 | + |
| 34 | + - name: Install jq |
| 35 | + run: | |
| 36 | + sudo apt-get update && sudo apt-get install -y jq |
| 37 | +
|
| 38 | + - name: Install deps and build website |
| 39 | + working-directory: website |
| 40 | + run: | |
| 41 | + npm ci |
| 42 | + |
| 43 | + npm run build |
| 44 | +
|
| 45 | + - name: Deploy draft preview to Netlify |
| 46 | + id: deploy |
| 47 | + working-directory: website |
| 48 | + env: |
| 49 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 50 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 51 | + run: | |
| 52 | + set -e |
| 53 | + BUILD_DIR="out" |
| 54 | + if [[ ! -d "$BUILD_DIR" ]]; then |
| 55 | + echo "Build output directory $BUILD_DIR not found" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + # Deploy the output that `npm run build` produced |
| 59 | + DEPLOY_JSON=$(netlify deploy --dir="$BUILD_DIR" --message="community PR #${{ github.event.number }}" --draft --json) |
| 60 | + echo "$DEPLOY_JSON" |
| 61 | + echo "url=$(echo "$DEPLOY_JSON" | jq -r '.deploy_url')" >> $GITHUB_OUTPUT |
| 62 | +
|
| 63 | + - name: Comment preview URL on PR |
| 64 | + if: success() |
| 65 | + uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b #v3.0.1 release https://github.com/thollander/actions-comment-pull-request/releases/tag/v3.0.1 |
| 66 | + with: |
| 67 | + github-token: ${{ secrets.GH_TOKEN }} |
| 68 | + message: | |
| 69 | + 🚀 **Docs preview deployed** |
| 70 | + → ${{ steps.deploy.outputs.url }} |
0 commit comments