From c53c8d533e6f617368858278e7ea6bf33b71517d Mon Sep 17 00:00:00 2001 From: Sam Mesterton-Gibbons Date: Thu, 14 Sep 2023 10:31:49 +0100 Subject: [PATCH 1/3] Only run docs upload on changes Updates CI pipeline to only upload documentation if there's been a change since the last successful build. --- .github/workflows/ci-workflow.yml | 32 ++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 683b2c5..f5b7185 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -18,9 +18,13 @@ jobs: CI: name: CI runs-on: ubuntu-22.04 + outputs: + shouldUpload: ${{ steps.shouldUpload.outputs.upload }} steps: - name: Check out repository code uses: actions/checkout@v3 + with: + fetch-depth: 0 # check out the entire repo history for SHA verification in lastSuccessful step - name: Lint specification run: make lint @@ -29,12 +33,34 @@ jobs: - name: Render API docs run: make render + ################################# + ## Upload deployable artefacts ## + ################################# + - name: Identify latest successful run + id: lastSuccessful + uses: SamhammerAG/last-successful-build-action@1c368a27a90596574a71ac0ede422a897d0e8e84 # @v4 + with: + branch: ${{ github.ref_name }} + workflow: ${{ github.workflow }} + verify: true + + - name: Determine if this workflow should upload artefacts + id: shouldUpload + shell: bash + run: | + if [ "${{ steps.lastSuccessful.outputs.sha }}" != "${{ github.sha }}" ] && [ "${{ github.ref_name }}" == "main" ] + then + echo "upload=true" >> $GITHUB_OUTPUT; + else + echo "upload=false" >> $GITHUB_OUTPUT; + fi + - name: Setup pages - if: ${{ inputs.forceDocsUpload || ( github.ref == 'refs/heads/main' ) }} + if: ${{ inputs.forceDocsUpload || ( steps.shouldUpload.outputs.upload == 'true' ) }} uses: actions/configure-pages@v3 - name: Upload documentation artifact - if: ${{ inputs.forceDocsUpload || ( github.ref == 'refs/heads/main' ) }} + if: ${{ inputs.forceDocsUpload || ( steps.shouldUpload.outputs.upload == 'true' ) }} uses: actions/upload-pages-artifact@v2 with: path: './api/docs' @@ -48,7 +74,7 @@ jobs: id-token: write runs-on: ubuntu-22.04 needs: CI - if: ${{ inputs.forceDocsUpload || ( github.ref == 'refs/heads/main' ) }} + if: ${{ inputs.forceDocsUpload || ( needs.CI.outputs.shouldUpload == 'true' ) }} steps: - name: Deploy documentation to GitHub Pages id: deployment From 1017dca5ad599606207d4ddb1816dbe85519ef2e Mon Sep 17 00:00:00 2001 From: Sam Mesterton-Gibbons Date: Thu, 14 Sep 2023 10:32:11 +0100 Subject: [PATCH 2/3] Slow down CI to only run weekly --- .github/workflows/ci-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index f5b7185..9e3eb34 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -2,7 +2,7 @@ name: CI Workflow run-name: ${{ format('{0} triggered {1} on {2}', (github.event_name == 'workflow_dispatch' && format('User {0}', github.actor) || format('{0} event', github.event_name) ), github.workflow, github.ref) }} on: schedule: - - cron: '0 4 * * 1-5' + - cron: '0 4 * * 1' push: From aea23a4586cabf3f5f0163c69fb8b13fd537c006 Mon Sep 17 00:00:00 2001 From: Sam Mesterton-Gibbons Date: Thu, 14 Sep 2023 20:35:46 +0100 Subject: [PATCH 3/3] Only run CI on PRs or push to main Co-authored-by: James Sandford --- .github/workflows/ci-workflow.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 9e3eb34..3c64b49 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -4,7 +4,11 @@ on: schedule: - cron: '0 4 * * 1' + pull_request: + push: + branches: + - 'main' workflow_dispatch: inputs: