Skip to content

Commit

Permalink
DOC: Issue-118 - Added build and deployment process of homepage to a …
Browse files Browse the repository at this point in the history
…GitHub actions based workflow, with no need to handle a new branch and push changes to it.
  • Loading branch information
mtwardawski committed Apr 11, 2024
1 parent a409bf9 commit 8f114e1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 48 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/homepage.yaml
Original file line number Diff line number Diff line change
@@ -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\"]' }}"
59 changes: 27 additions & 32 deletions .github/workflows/job-homepage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
8 changes: 0 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down

0 comments on commit 8f114e1

Please sign in to comment.