From ac5fd6202107b43441012838cb79cf427f47b4e4 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Wed, 6 Mar 2024 17:27:49 +0100 Subject: [PATCH] Publish GitHub pages with explicit GitHub Action Steps (#2461) This should, if it works, make the exact same website content that we currently have up on https://google.github.io/android-fhir/ appear. What changes is that instead of GitHub "implicitly" building it for us, via its https://github.com/google/android-fhir/actions/workflows/pages/, we "control" it - which allows us hook our own documentation build steps into it. All the magic GitHub Workflow Action YAML gobbledygook introduced here is inspired by https://github.com/enola-dev/enola/blob/ed2b1755b9dbf1a0668c86f80048d8bded94de4a/.github/workflows/ci.yaml#L131, where I learnt how to do this to create https://docs.enola.dev. --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc500cc5e8..b421694ab0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,6 +96,40 @@ jobs: path: build.zip # Steps that follow are related to the Documentation Web Site + # This deploys content based on docs/ which ends up in site/ + # to https://google.github.io/android-fhir/ using GitHub Pages. - name: Build Docs Site + # This 1st step intentionally runs not just on the main ("master") branch + # but also for all pull requests. This serves to detect doc breakages. + # (But the following steps, which do the actual deploy, only run for + # the main branch, of course.) run: ./build-docs.bash + + - name: Setup GitHub Pages + if: ${{ github.event_name == 'push' }} + uses: actions/configure-pages@v4 + + - name: Upload site/ directory as GitHub Pages artifact + if: ${{ github.event_name == 'push' }} + uses: actions/upload-pages-artifact@v3 + with: + path: "site/" + + deploy-website: + needs: build + if: ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication + # Sets required permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages. + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + # https://github.com/actions/deploy-pages + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4