From 7e01065a9298d3edbfceac029e002b7916822c1e Mon Sep 17 00:00:00 2001 From: Uli <98144814+uli-f@users.noreply.github.com> Date: Thu, 10 Jul 2025 15:59:33 +1000 Subject: [PATCH 1/2] add CI pipeline and deploy workflow for GitHub Pages --- .github/workflows/ci.yaml | 56 +++++++++++++++++++++++++++++++++++ .github/workflows/deploy.yaml | 42 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..19b34d9 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,56 @@ +name: CI Pipeline +# Produces production artifact, uploads it as workflow artifact + +on: + push: + branches: [source] + paths-ignore: + - '**.md' + + pull_request: + branches: [source] + paths-ignore: + - '**.md' + + # allows this workflow to be run from another + workflow_call: + + # allows running this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: 'ubuntu-22.04' + steps: + - name: ๐Ÿ›ซ Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: ๐Ÿงถ Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: 'package.json' + cache: 'npm' + + - name: ๐Ÿ‘ฉโ€๐Ÿ”ง Install dependencies + run: npm clean-install + + - name: ๐Ÿ“ฆ Build for production + id: build_step + run: npm run production 2>&1 | tee build-output.log + + - name: ๐Ÿ“ค Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + # only run if on source branch or on a tag + if: ${{ github.ref == 'refs/heads/source' || startsWith( github.ref, 'refs/tags/' )}} + with: + path: dist/ + + - name: ๐Ÿ“ Generate workflow summary + run: | + echo "### ๐Ÿ“ฆ Webpack Build Summary" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + cat build-output.log >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..7000f3a --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,42 @@ +name: Deploy to GitHub Pages + +on: + release: + types: [ 'published' ] + + # allows running this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: read # required for git checkout + pages: write # to deploy to GitHub Pages + id-token: write # to verify the deployment originates from an appropriate source + actions: write # required to write a job summary + +jobs: + ci: + name: ๐Ÿš€ CI + uses: ./.github/workflows/ci.yaml + permissions: + contents: read + actions: write # required to write a job summary + + # Deploys Pages artifact to GitHub Pages. + deploy-pages-artifact: + name: Deploy Pages Artifact to GitHub Pages + needs: ci + # Deploy to github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: 'ubuntu-24.04' + steps: + # Deploy the artifact from the 'ci' job + - name: ๐Ÿš€ Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + + - name: ๐Ÿ“ Generate deployment summary + run: | + echo "### ๐Ÿš€ Deployment Summary" >> $GITHUB_STEP_SUMMARY + echo "Website deployed to: ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY \ No newline at end of file From 2bb0d83a2e9fe190871ca3699ae7acdc6a127d90 Mon Sep 17 00:00:00 2001 From: Uli <98144814+uli-f@users.noreply.github.com> Date: Thu, 10 Jul 2025 16:07:47 +1000 Subject: [PATCH 2/2] sanitize ANSI escape codes from Webpack build logs in CI summary --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 19b34d9..97a6a72 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,5 +52,5 @@ jobs: run: | echo "### ๐Ÿ“ฆ Webpack Build Summary" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - cat build-output.log >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + sed -r "s/\x1B\[[0-9;]*[mK]//g" build-output.log >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY \ No newline at end of file