From 8f114e162c4008fc1cc952f3e0fd96464cdf98d3 Mon Sep 17 00:00:00 2001 From: Matthias Twardawski Date: Thu, 11 Apr 2024 11:17:40 +0200 Subject: [PATCH] DOC: Issue-118 - Added build and deployment process of homepage to a GitHub actions based workflow, with no need to handle a new branch and push changes to it. --- .github/workflows/build.yaml | 8 ---- .github/workflows/homepage.yaml | 30 +++++++++++++++ .github/workflows/job-homepage.yaml | 59 +++++++++++++---------------- .github/workflows/release.yaml | 8 ---- 4 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/homepage.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 73ec58db0..901b9004e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -37,14 +37,6 @@ jobs: with: runs-on: "${{ vars.OPENDUT_GH_RUNNER_LARGE || '[\"ubuntu-latest\"]' }}" - homepage: - uses: ./.github/workflows/job-homepage.yaml - permissions: - contents: write - pages: write - with: - runs-on: "${{ vars.OPENDUT_GH_RUNNER_LARGE || '[\"ubuntu-latest\"]' }}" - build-carl: uses: ./.github/workflows/job-build-carl.yaml needs: [ test ] diff --git a/.github/workflows/homepage.yaml b/.github/workflows/homepage.yaml new file mode 100644 index 000000000..c0521b37b --- /dev/null +++ b/.github/workflows/homepage.yaml @@ -0,0 +1,30 @@ +name: homepage +on: + workflow_dispatch: # manual trigger + inputs: + run-testenv: + description: "Run the build and deployment process of the OpenDuT homepage." + required: false + type: string + default: "false" + pull_request: + types: [ opened, reopened, synchronize, edited, ready_for_review ] + push: + branches: [ + "main", + "development" + ] + tags: + - v[0-9]+.[0-9]+.[0-9]+ + - v[0-9]+.[0-9]+.[0-9]+-* + - canary + +jobs: + homepage: + uses: ./.github/workflows/job-homepage.yaml + permissions: + contents: read + pages: write + id-token: write + with: + runs-on: "${{ vars.OPENDUT_GH_RUNNER_LARGE || '[\"ubuntu-latest\"]' }}" \ No newline at end of file diff --git a/.github/workflows/job-homepage.yaml b/.github/workflows/job-homepage.yaml index d4a985f1b..152427600 100644 --- a/.github/workflows/job-homepage.yaml +++ b/.github/workflows/job-homepage.yaml @@ -7,10 +7,6 @@ on: required: false type: string -permissions: - contents: write - pages: write - jobs: check_documentation_changed: name: Check if documentation has changed and a new deploy is needed @@ -26,20 +22,26 @@ jobs: documentation: - 'doc/**' - 'opendut-homepage/**' + base: main build_homepage: name: Build the homepage and upload artifact + if: ${{ needs.check_documentation_changed.outputs.documentation == 'true' && (github.ref_name == 'main' || github.ref_name == 'development' || github.ref_type == 'tag') }} runs-on: ${{ fromJson(inputs.runs-on) }} needs: check_documentation_changed steps: - name: Checkout sources uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + + - name: Configure GitHub Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b + - name: Rust setup uses: ./.github/actions/rust-setup - with: - cargo-deny: true + - name: Build homepage run: cargo ci doc homepage build + - name: Upload homepage artifact uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 with: @@ -48,31 +50,24 @@ jobs: if-no-files-found: error retention-days: 1 - homepage_build_deploy: # Triggered if pushed on Main, Development or when tagged, also triggered if something changed in doc folder or in opendut-homapge folder - name: Release homepage (Changes in doc/opendut-homepage folder and Push on Main or Development or tagged) - needs: [check_documentation_changed, build_homepage] - runs-on: ${{ fromJson(inputs.runs-on) }} - steps: - - name: Checkout sources - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - - name: Download Homepage Files - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa with: - pattern: "homepage" + path: "./target/ci/homepage" - - name: Prepare branch and commit - if: ${{ needs.check_documentation_changed.outputs.documentation == 'true' && (github.ref_name == 'main' || github.ref_name == 'development' || github.ref_type == 'tag') }} - run: | - cd /home/runner/work/opendut/opendut - git fetch --all - git config user.email github-actions@github.com - git config user.name github-actions - git config alias.switchorcreateorphan '!f() { (git checkout $1 2>/dev/null && echo "SWITCHED") || (git switch --orphan $1 && echo "ORPHANED"); }; f' - git switchorcreateorphan github-pages - rsync -v --recursive --checksum --whole-file /home/runner/work/opendut/opendut/homepage/ /home/runner/work/opendut/opendut - rm -rf homepage/ - git add -A - git status - git commit -m "Push homepage" - git push -u origin github-pages + deploy_homepage: + name: Deploy the created homepage artifacts to GitHub Pages + if: ${{ needs.check_documentation_changed.outputs.documentation == 'true' && (github.ref_name == 'main' || github.ref_name == 'development' || github.ref_type == 'tag') }} + permissions: + contents: read + pages: write + id-token: write + runs-on: ${{ fromJson(inputs.runs-on) }} + needs: build_homepage + environment: + name: github-pages + url: ${{steps.deployment.outputs.page_url}} + steps: + - name: Deploy artifact + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d53a08d00..73cc6c59e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,14 +28,6 @@ jobs: with: runs-on: "${{ vars.OPENDUT_GH_RUNNER_LARGE || '[\"ubuntu-latest\"]' }}" - homepage: - uses: ./.github/workflows/job-homepage.yaml - permissions: - contents: write - pages: write - with: - runs-on: "${{ vars.OPENDUT_GH_RUNNER_LARGE || '[\"ubuntu-latest\"]' }}" - build-carl: uses: ./.github/workflows/job-build-carl.yaml needs: [ test ]