From 4092ad6b171d82b329ff8ba4fee279b41efd5e49 Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Tue, 27 Aug 2024 21:11:48 -0700 Subject: [PATCH] Create website.yml --- .github/workflows/website.yml | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 00000000..ad346360 --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,54 @@ +name: website + +on: + push: + branches: + - '*-release' + +jobs: + check_branch: + runs-on: ubuntu-latest + outputs: + should_deploy: ${{ endsWith(github.ref, steps.get_version.outputs.latest) }} + + steps: + - name: Get version + id: get_version + run: | + packageFile=$(if [ -d modules ]; then ls modules/*/package.json | head -n 1; else echo package.json; fi) + packageName=$(jq -r '.name' $packageFile) + LATEST=$(npm show "${packageName}@latest" version | grep -o -E "^[0-9]+\.[0-9]+") + echo "latest=${LATEST}-release" >> "$GITHUB_OUTPUT" + + deploy: + runs-on: ubuntu-latest + needs: check_branch + + permissions: + contents: write + + if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_deploy }} + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + token: ${{ secrets.WEBSITE_DEPLOY_TOKEN }} + - uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 + with: + cache: 'yarn' + + - name: Install dependencies + run: | + yarn + (cd website && yarn) + + - name: Build website + run: (cd website && yarn build) + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@132898c54c57c7cc6b80eb3a89968de8fc283505 # 3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: website/build + CLEAN: true