From 2e33f37cee8217135c058427180bad436a59b8b7 Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Tue, 15 Nov 2022 11:10:53 +0530 Subject: [PATCH] CI for website (#1469) ## Description CI for website, useful for dependabot tests. ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [x] :computer: CI/Deployment - [ ] :hamster: Trivial/Minor ## Issue(s) * # ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E Co-authored-by: Vaibhav Kamra --- .github/workflows/_filechange_checker.yml | 15 +++++++++- .github/workflows/website-ci.yml | 34 +++++++++++++++++++++++ website/Makefile | 5 ++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/website-ci.yml diff --git a/.github/workflows/_filechange_checker.yml b/.github/workflows/_filechange_checker.yml index f07dea447..60dd89f19 100644 --- a/.github/workflows/_filechange_checker.yml +++ b/.github/workflows/_filechange_checker.yml @@ -9,6 +9,9 @@ on: docfileschanged: description: "'true' if docs/** or src/** or .github/workflows/** files have changed in the branch" value: ${{ jobs.file-change-check.outputs.docfileschanged }} + websitefileschanged: + description: "'true' if websites/** or .github/workflows/** files have changed in the branch" + value: ${{ jobs.file-change-check.outputs.websitefileschanged }} jobs: file-change-check: @@ -19,6 +22,7 @@ jobs: outputs: srcfileschanged: ${{ steps.srcchecker.outputs.srcfileschanged }} docfileschanged: ${{ steps.docchecker.outputs.docfileschanged }} + websitefileschanged: ${{ steps.websitechecker.outputs.websitefileschanged }} steps: - uses: actions/checkout@v3 @@ -33,6 +37,8 @@ jobs: - 'src/**' docs: - 'docs/**' + website: + - 'website/**' actions: - '.github/workflows/**' - '.github/actions/**' @@ -49,4 +55,11 @@ jobs: if: steps.dornycheck.outputs.src == 'true' || steps.dornycheck.outputs.docs == 'true' || steps.dornycheck.outputs.actions == 'true' run: | echo "docs, src or workflow file changes occurred" - echo ::set-output name=docfileschanged::true \ No newline at end of file + echo ::set-output name=docfileschanged::true + + - name: Check dorny for changes in website related filepaths + id: websitechecker + if: steps.dornycheck.outputs.website == 'true' || steps.dornycheck.outputs.actions == 'true' + run: | + echo "website or workflow file changes occurred" + echo ::set-output name=websitefileschanged::true \ No newline at end of file diff --git a/.github/workflows/website-ci.yml b/.github/workflows/website-ci.yml new file mode 100644 index 000000000..ee94dd808 --- /dev/null +++ b/.github/workflows/website-ci.yml @@ -0,0 +1,34 @@ +name: CI for Website +on: + workflow_dispatch: + pull_request: + push: + branches: [main] + +# cancel currently running jobs if a new version of the branch is pushed +concurrency: + group: website-ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + Precheck: + uses: alcionai/corso/.github/workflows/_filechange_checker.yml@main + + Website-Build: + needs: [Precheck] + environment: Testing + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' || needs.precheck.outputs.websitefileschanged == 'true' + defaults: + run: + working-directory: website + steps: + - uses: actions/checkout@v3 + + - name: Build website image + run: | + make buildimage + + - name: Build website + run: | + make build diff --git a/website/Makefile b/website/Makefile index a7172e277..53f0adbe4 100644 --- a/website/Makefile +++ b/website/Makefile @@ -2,6 +2,11 @@ WEBC := docker run --rm -it --init -p 5050:3000 -p 5051:3001 \ -v ${PWD}:/usr/src/website corso/website:latest +ifeq (${CI},true) +# Cannot run in interactive/tty mode in CI +WEBC := docker run --rm --init -p 5050:3000 -p 5051:3001 \ + -v ${PWD}:/usr/src/website corso/website:latest +endif buildimage: clean docker build -t "corso/website:latest" .