improve workflow #83
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and deploy GH Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| repository_dispatch: | |
| types: [slave-trade-map-updated] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: github.ref != 'refs/heads/main' | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: build | |
| uses: shalzz/zola-deploy-action@v0.22.1 | |
| env: | |
| BUILD_DIR: . | |
| TOKEN: ${{ secrets.ACTIONS_TOKEN }} | |
| BUILD_ONLY: true | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull slave-trade-map artifacts | |
| run: | | |
| set -euxo pipefail | |
| CONTAINER_ID=$(docker create ghcr.io/afbase/slave-trade-map:latest sh) | |
| mkdir -p themes/adidoks/static/slave-trade-map | |
| docker cp "${CONTAINER_ID}:/dist/." themes/adidoks/static/slave-trade-map/ | |
| docker rm "${CONTAINER_ID}" | |
| # Remove Dioxus index.html so Zola template renders instead | |
| rm -f themes/adidoks/static/slave-trade-map/index.html | |
| # Copy CSS/WASM from assets/ to root so Dioxus can find them via relative paths | |
| cp themes/adidoks/static/slave-trade-map/assets/*.css themes/adidoks/static/slave-trade-map/ 2>/dev/null || true | |
| cp themes/adidoks/static/slave-trade-map/assets/*.wasm themes/adidoks/static/slave-trade-map/ 2>/dev/null || true | |
| # Create stable-named entry JS with fixed asset paths | |
| ENTRY_JS=$(find themes/adidoks/static/slave-trade-map/assets -maxdepth 1 -name 'slave-trade-map-*.js' | head -1) | |
| if [ -n "$ENTRY_JS" ]; then | |
| sed 's|"/\./assets/|"/slave-trade-map/assets/|g' "$ENTRY_JS" > themes/adidoks/static/slave-trade-map/assets/slave-trade-map-entry.js | |
| fi | |
| - name: build and deploy | |
| uses: shalzz/zola-deploy-action@v0.22.1 | |
| env: | |
| PAGES_BRANCH: gh-pages | |
| BUILD_DIR: . | |
| GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }} | |
| - name: Add CNAME to gh-pages | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }} | |
| run: | | |
| git clone --depth 1 --branch "gh-pages" "https://${GITHUB_TOKEN}@github.com/afbase/slavecodes_org.git" gh-pages-clone | |
| cd gh-pages-clone | |
| echo "slavecodes.org" > CNAME | |
| git config --local user.email "afbase@users.noreply.github.com" | |
| git config --local user.name "clinton bowen" | |
| git add CNAME | |
| git commit -m "Update CNAME file" || echo "No changes to commit" | |
| git push |