Skip to content

Merge pull request #61 from Unity-Lab-AI/codex/add-mocked-tests-for-p… #63

Merge pull request #61 from Unity-Lab-AI/codex/add-mocked-tests-for-p…

Merge pull request #61 from Unity-Lab-AI/codex/add-mocked-tests-for-p… #63

Workflow file for this run

name: Deploy GitHub Pages
on:
push:
branches:
- main
# Manual trigger
workflow_dispatch:
# Optional: run when using GitHub merge queue
merge_group:
permissions:
contents: read
actions: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
tests:
name: Run Test Suites
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run tests
run: |
npm test
- name: Capture test status
id: capture
run: |
cat tests/test-results.json
node -e "const fs=require('fs');const r=JSON.parse(fs.readFileSync('tests/test-results.json','utf8'));fs.appendFileSync(process.env.GITHUB_OUTPUT,`status=${r.status}\n`);"
- name: Report test summary
run: |
node -e "const fs=require('fs');const r=JSON.parse(fs.readFileSync('tests/test-results.json','utf8'));console.log('# Test Summary');console.log('PolliLib',r.groups.pollilib.passed,'/',r.groups.pollilib.total);console.log('Site',r.groups.site.passed,'/',r.groups.site.total);console.log('Overall',r.passed,'/',r.total,'->',r.status);" >> $GITHUB_STEP_SUMMARY
build:
name: Build and Upload Artifact
needs: tests
if: needs.tests.outputs.status != 'fail'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Summarize build
run: |
echo "# Build Summary" >> $GITHUB_STEP_SUMMARY
echo "Event: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "Ref: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY
echo "Commit: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
- name: Disable Jekyll
run: echo > .nojekyll
# No bundling needed; publish repo root
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: .
report-build-status:
name: Report Build Status
needs: [build, tests]
runs-on: ubuntu-latest
if: always()
steps:
- name: Report build status to Pages telemetry
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_RESULT: ${{ needs.build.result }}
run: |
set +e
gh --version
# Determine conclusion from the build job result, mapping to accepted values
CONCLUSION="$BUILD_RESULT"
case "$CONCLUSION" in
success) ;;
failure) ;;
cancelled|skipped) CONCLUSION="cancelled" ;;
*) CONCLUSION="neutral" ;;
esac
# Only attempt telemetry when the run exists
if gh api -X GET "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >/dev/null 2>&1; then
echo "Reporting telemetry: run=$GITHUB_RUN_ID conclusion=$CONCLUSION"
gh api -X POST "repos/$GITHUB_REPOSITORY/pages/telemetry" \
-F github_run_id="$GITHUB_RUN_ID" \
-F conclusion="$CONCLUSION" \
&& echo "Telemetry reported" \
|| echo "::notice::Pages telemetry endpoint non-2xx; skipping."
else
echo "::notice::Workflow run $GITHUB_RUN_ID not found for telemetry; skipping."
fi
deploy:
name: Deploy to Pages
needs: build
# Runs only on push to main, merge_group, or manual dispatch
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4