Skip to content

Merge pull request #71 from mskilab-org/fix/minor-bugs #99

Merge pull request #71 from mskilab-org/fix/minor-bugs

Merge pull request #71 from mskilab-org/fix/minor-bugs #99

name: Build and Publish Artifacts
on:
push:
branches: ["main"]
permissions:
contents: write
pages: write
id-token: write
# Cancel in-flight older runs if you push again
concurrency:
group: build-artifacts
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node 23
uses: actions/setup-node@v4
with:
node-version: "23.x"
cache: "yarn"
- name: Install deps
run: yarn install --frozen-lockfile
- name: Build
env:
# give webpack more headroom; harmless on CI
NODE_OPTIONS: --max-old-space-size=4096
REACT_APP_RELEASE_TAG: build-${{ github.sha }}
REACT_APP_RELEASE_COMMIT: ${{ github.sha }}
# optional: smaller uploads
# GENERATE_SOURCEMAP: 'false'
run: CI=false yarn build
- name: Package build as tar.gz
id: package
run: |
set -e
mkdir -p out
# timestamp tag for proper sorting
TIMESTAMP=$(date -u +"%Y.%m.%d-%H%M%S")
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
RELEASE_TAG="build-${TIMESTAMP}-${SHORT_SHA}"
TARBALL="${RELEASE_TAG}.tar.gz"
tar -czf "out/${TARBALL}" -C build .
sha256sum "out/${TARBALL}" > "out/${TARBALL}.sha256"
echo "${GITHUB_SHA}" > out/LATEST.txt
BUILT_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "${BUILT_AT}" > out/LATEST_BUILT_AT.txt
{
echo "tarball=out/${TARBALL}"
echo "checksum=out/${TARBALL}.sha256"
echo "release_tag=${RELEASE_TAG}"
echo "built_at=${BUILT_AT}"
} >> "$GITHUB_OUTPUT"
- name: Publish release with assets
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.package.outputs.release_tag }}
name: Edge build ${{ github.sha }}
body: |
Automated build from commit ${{ github.sha }}.
Built at ${{ steps.package.outputs.built_at }}.
draft: false
prerelease: true
makeLatest: false
allowUpdates: true
replacesArtifacts: true
artifactErrorsFailBuild: true
artifacts: |
${{ steps.package.outputs.tarball }}
${{ steps.package.outputs.checksum }}
out/LATEST.txt
out/LATEST_BUILT_AT.txt
token: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare static site (shared data + latest release)
env:
TAG: ${{ steps.package.outputs.release_tag }}
REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SKIP_SERVER: "1"
PORT: "3001"
SITE_DIR: "site"
run: |
set -euo pipefail
./setup.sh
mv "out/$TAG" "$SITE_DIR"
- name: Upload artifact for Pages
uses: actions/upload-pages-artifact@v3
with:
path: site
deploy-pages:
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4