From dd2a4b918c661ad0aa6975128681b27acac001b2 Mon Sep 17 00:00:00 2001 From: KW Kwan Date: Tue, 21 Nov 2023 16:02:24 +0800 Subject: [PATCH] Migrate site to Github Pages --- .github/workflows/build_deploy.yml | 73 ++++++++++++++++++++++++++++ .github/workflows/deploy-convert.yml | 60 ----------------------- .github/workflows/links.yml | 55 +++++++++++++++++++++ 3 files changed, 128 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/build_deploy.yml delete mode 100644 .github/workflows/deploy-convert.yml create mode 100644 .github/workflows/links.yml diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml new file mode 100644 index 0000000..4fec7b9 --- /dev/null +++ b/.github/workflows/build_deploy.yml @@ -0,0 +1,73 @@ +name: build_deploy + +on: + push: + branches: + - master + # - staging + pull_request: + repository_dispatch: + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + environment: + name: production + steps: + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: '18.x' + + - uses: actions/checkout@master + + - name: Enable Yarn Berry + run: | + corepack enable + corepack prepare yarn@stable --activate + # - name: Compile all packages + # # TODO: Get rid of, the esbuild step should be sufficient. + # # However, currently some packages rely on `compiled/` paths, + # # which are created by running `compile` commands. + # run: | + # yarn compile-all + + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 + + - name: Build site + run: | + yarn workspace webgui build --debug + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + name: webgui-dist + path: packages/webgui/dist/ + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + if: ${{ github.ref == 'refs/heads/master' }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/deploy-convert.yml b/.github/workflows/deploy-convert.yml deleted file mode 100644 index 063209c..0000000 --- a/.github/workflows/deploy-convert.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: deploy-master - -on: - schedule: - - cron: '42 */12 * * *' - push: - branches: [ master ] - workflow_dispatch: - -jobs: - build: - name: Build site - runs-on: ubuntu-latest - environment: - name: production - steps: - - name: Use Node - uses: actions/setup-node@v2 - with: - node-version: '18.x' - - uses: actions/checkout@master - - name: Enable Yarn Berry - run: | - corepack enable - corepack prepare yarn@stable --activate - # - name: Compile all packages - # # TODO: Get rid of, the esbuild step should be sufficient. - # # However, currently some packages rely on `compiled/` paths, - # # which are created by running `compile` commands. - # run: | - # yarn compile-all - - name: Build site - run: | - yarn workspace webgui build --debug - - - name: Upload built site artifact - uses: actions/upload-artifact@v3 - with: - name: webgui-dist - path: packages/webgui/dist - - - name: Deploy to AWS - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_REGION: ${{ secrets.AWS_REGION }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} - S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} - run: | - aws configure set default.s3.max_concurrent_requests 100 - aws configure set default.s3.max_queue_size 10000 - aws configure set default.s3.use_accelerate_endpoint true - aws configure set default.s3.payload_signing_enabled false - aws s3 sync packages/webgui/dist s3://$S3_BUCKET_NAME --region=$AWS_REGION --delete --no-progress --exclude "*" --include "*.html" --content-type "text/html; charset=utf-8" - aws s3 sync packages/webgui/dist s3://$S3_BUCKET_NAME --region=$AWS_REGION --delete --no-progress --exclude "*" --include "*.json" --content-type "application/json; charset=utf-8" - aws s3 sync packages/webgui/dist s3://$S3_BUCKET_NAME --region=$AWS_REGION --delete --no-progress --exclude "*" --include "*.jsonld" --content-type "application/ld+json; charset=utf-8" - aws s3 sync packages/webgui/dist s3://$S3_BUCKET_NAME --region=$AWS_REGION --delete --no-progress --exclude "*" --include "*.ttl" --content-type "text/turtle; charset=utf-8" - aws s3 sync packages/webgui/dist s3://$S3_BUCKET_NAME --region=$AWS_REGION --delete --no-progress --include "*" --exclude "*.html" --exclude "*.json" --exclude "*.jsonld" --exclude "*.ttl" - aws configure set preview.cloudfront true - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml new file mode 100644 index 0000000..78e2376 --- /dev/null +++ b/.github/workflows/links.yml @@ -0,0 +1,55 @@ +name: links + +on: + push: + branches: + - master + - staging + pull_request: + +jobs: + link_checker: + runs-on: ubuntu-latest + environment: + name: production + steps: + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: '18.x' + + - uses: actions/checkout@master + + - name: Enable Yarn Berry + run: | + corepack enable + corepack prepare yarn@stable --activate + # - name: Compile all packages + # # TODO: Get rid of, the esbuild step should be sufficient. + # # However, currently some packages rely on `compiled/` paths, + # # which are created by running `compile` commands. + # run: | + # yarn compile-all + + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 + + - name: Build site + run: | + yarn workspace webgui build --debug + + - name: Link Checker + uses: lycheeverse/lychee-action@v1.2.0 + with: + args: --verbose --no-progress --exclude-file .lycheeignore -- _site/**/*.html + fail: true + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + # - name: Create Issue From File + # uses: peter-evans/create-issue-from-file@v2 + # with: + # title: Link Checker Report + # content-filepath: ./lychee/out.md + # labels: report, automated issue