|
| 1 | +name: 🛠️ Build PR Preview |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: ${{github.event.pull_request.head.ref}} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + metadata: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + submodules: ${{ steps.submodules-fork.outputs.submodules || steps.submodules-main.outputs.submodules }} |
| 18 | + privileged: ${{ steps.submodules-fork.outputs.privileged || steps.submodules-main.outputs.privileged }} |
| 19 | + env: |
| 20 | + ACTIONS_SSH_KEY: ${{ secrets.ACTIONS_SSH_KEY }} |
| 21 | + steps: |
| 22 | + - name: Set submodules for fork |
| 23 | + if: env.ACTIONS_SSH_KEY == '' |
| 24 | + id: submodules-fork |
| 25 | + run: | |
| 26 | + echo 'submodules={"repo":["brand","i18n"]}' >> "$GITHUB_OUTPUT" |
| 27 | + echo "privileged=false" >> "$GITHUB_OUTPUT" |
| 28 | +
|
| 29 | + - name: Set submodules for main repo |
| 30 | + if: env.ACTIONS_SSH_KEY != '' |
| 31 | + id: submodules-main |
| 32 | + run: | |
| 33 | + echo 'submodules={"repo":["brand","i18n","mkdocs-material-insiders"]}' >> "$GITHUB_OUTPUT" |
| 34 | + echo "privileged=true" >> "$GITHUB_OUTPUT" |
| 35 | +
|
| 36 | + - name: Save PR metadata |
| 37 | + run: | |
| 38 | + mkdir -p ./metadata |
| 39 | + echo ${{ github.event.number }} > ./metadata/NR |
| 40 | + echo ${{ github.event.pull_request.head.sha }} > ./metadata/SHA |
| 41 | +
|
| 42 | + - name: Upload metadata as artifact |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: metadata |
| 46 | + path: metadata |
| 47 | + |
| 48 | + submodule: |
| 49 | + needs: metadata |
| 50 | + strategy: |
| 51 | + matrix: ${{ fromJson(needs.metadata.outputs.submodules) }} |
| 52 | + uses: privacyguides/.github/.github/workflows/download-repo.yml@main |
| 53 | + with: |
| 54 | + repo: ${{ matrix.repo }} |
| 55 | + privileged: ${{ fromJSON(needs.metadata.outputs.privileged) }} |
| 56 | + secrets: |
| 57 | + ACTIONS_SSH_KEY: ${{ secrets.ACTIONS_SSH_KEY }} |
| 58 | + |
| 59 | + build_english: |
| 60 | + needs: [submodule, metadata] |
| 61 | + strategy: |
| 62 | + matrix: |
| 63 | + lang: [en] |
| 64 | + fail-fast: true |
| 65 | + uses: ./.github/workflows/build.yml |
| 66 | + with: |
| 67 | + ref: ${{github.event.pull_request.head.ref}} |
| 68 | + repo: ${{github.event.pull_request.head.repo.full_name}} |
| 69 | + lang: en |
| 70 | + continue-on-error: false |
| 71 | + privileged: ${{ fromJSON(needs.metadata.outputs.privileged) }} |
| 72 | + |
| 73 | + build_i18n: |
| 74 | + if: ${{ contains(github.event.pull_request.labels.*.name, 'ci:build i18n') }} |
| 75 | + needs: [submodule, metadata] |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + lang: [es, fr, he, it, nl, ru, zh-Hant] |
| 79 | + fail-fast: false |
| 80 | + uses: ./.github/workflows/build.yml |
| 81 | + with: |
| 82 | + ref: ${{github.event.pull_request.head.ref}} |
| 83 | + repo: ${{github.event.pull_request.head.repo.full_name}} |
| 84 | + lang: ${{ matrix.lang }} |
| 85 | + continue-on-error: true |
| 86 | + privileged: ${{ fromJSON(needs.metadata.outputs.privileged) }} |
| 87 | + |
| 88 | + combine_build: |
| 89 | + needs: [build_english, build_i18n] |
| 90 | + if: | |
| 91 | + (always() && !cancelled() && !failure()) && |
| 92 | + needs.build_english.result == 'success' && |
| 93 | + (needs.build_i18n.result == 'success' || needs.build_i18n.result == 'skipped') |
| 94 | +
|
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + pattern: site-build-* |
| 100 | + merge-multiple: true |
| 101 | + |
| 102 | + - run: | |
| 103 | + for file in *.tar.gz; do tar -zxf "$file"; done |
| 104 | + ls -la site/ |
| 105 | +
|
| 106 | + - name: Upload Site |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: site-build-combined |
| 110 | + path: site |
| 111 | + retention-days: 5 |
| 112 | + |
| 113 | + cleanup: |
| 114 | + if: ${{ always() }} |
| 115 | + needs: [build_english, build_i18n] |
| 116 | + uses: privacyguides/.github/.github/workflows/cleanup.yml@main |
0 commit comments