diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml new file mode 100644 index 000000000..0f2448846 --- /dev/null +++ b/.github/workflows/pr-build.yml @@ -0,0 +1,29 @@ +# build-preview.yml +name: PR Build Preview for Cloudflare + +on: + pull_request: + types: [opened, synchronize] + +jobs: + build-preview: + runs-on: ubuntu-latest + name: Build Preview Site and Upload Build Artifact + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install requirements + run: pip install -r requirements.txt + - name: Build PR + run: mkdocs build + + # Uploads the build directory as a workflow artifact + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: preview-build + path: site diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml new file mode 100644 index 000000000..705e7264a --- /dev/null +++ b/.github/workflows/pr-deploy.yml @@ -0,0 +1,39 @@ +# deploy-preview.yml +name: PR Upload Preview to Cloudflare +on: + workflow_run: + workflows: ['PR Build Preview for Cloudflare'] + types: + - completed + +permissions: + actions: read + deployments: write + contents: read + pull-requests: write + +jobs: + deploy-preview: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Deploy Preview to Cloudflare Pages + steps: + # Downloads the build directory from the previous workflow + - name: Download build artifact + uses: actions/download-artifact@v4 + id: preview-build-artifact + with: + name: preview-build + path: build + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Deploy to Cloudflare Pages + uses: AdrianGonz97/refined-cf-pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT_ID }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectName: ${{ secrets.CLOUDFLARE_DOCS_PROJECT }} + deploymentName: Preview + directory: ${{ steps.preview-build-artifact.outputs.download-path }}