Add some discord stuff #96
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 | |
| on: | |
| push: | |
| branches: ["master"] | |
| workflow_dispatch: | |
| env: | |
| INSTANCE: 'Writerside/1' | |
| DOCKER_VERSION: '243.22562' | |
| CF_ACC_ID: ${{ secrets.CF_ACC_ID }} | |
| CF_API_TOK: ${{ secrets.CF_API_TOK }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| zip_path: ${{ steps.discover.outputs.zip_path }} | |
| build_dir: ${{ steps.discover.outputs.build_dir }} | |
| algolia_zip: ${{ steps.discover.outputs.algolia_zip }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Writerside Build | |
| uses: JetBrains/writerside-github-action@v4 | |
| with: | |
| instance: ${{ env.INSTANCE }} | |
| docker-version: ${{ env.DOCKER_VERSION }} | |
| - name: Discover Build Artifacts | |
| id: discover | |
| run: | | |
| echo "Workspace contents:" | |
| find . -type f -maxdepth 3 | sed 's/^/ /' | |
| ZIP_PATH=$(find artifacts -type f -name '*.zip' ! -name 'algolia-indexes-*.zip' | head -n1) | |
| ALG_ZIP=$(find artifacts -type f -name 'algolia-indexes-*.zip' | head -n1) | |
| if [ -z "$ZIP_PATH" ]; then | |
| echo "❌ No ZIP found under artifacts/—check Writerside action output!" | |
| exit 1 | |
| fi | |
| BUILD_DIR="${ZIP_PATH%.zip}" | |
| echo "Found ZIP: $ZIP_PATH" | |
| echo "Derived build_dir: $BUILD_DIR" | |
| echo "zip_path=$ZIP_PATH" >> "$GITHUB_OUTPUT" | |
| echo "build_dir=$BUILD_DIR" >> "$GITHUB_OUTPUT" | |
| echo "algolia_zip=$ALG_ZIP" >> "$GITHUB_OUTPUT" | |
| - name: Upload Build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: zip | |
| path: ${{ steps.discover.outputs.zip_path }} | |
| - name: Upload Algolia | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: algolia-zip | |
| path: ${{ steps.discover.outputs.algolia_zip }} | |
| deploy-cf: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zip | |
| path: . | |
| - name: Debug - List Everything | |
| run: | | |
| echo "Working directory: $(pwd)" | |
| echo "Contents of repo root:" | |
| ls -R . | sed 's/^/ /' | |
| - name: Unzip Writerside Output | |
| run: | | |
| ZIP_FILE="$(basename '${{ needs.build.outputs.zip_path }}')" | |
| DEST="${{ needs.build.outputs.build_dir }}" | |
| echo "Unzipping $ZIP_FILE into $DEST" | |
| mkdir -p "$DEST" | |
| unzip "$ZIP_FILE" -d "$DEST" | |
| - name: Copy verification files into build root | |
| run: | | |
| DEST="${{ needs.build.outputs.build_dir }}" | |
| echo "Copying verification files to $DEST" | |
| # GitHub-stored verification files: | |
| cp_if_exists() { | |
| SRC="$1" | |
| if [ -f "$SRC" ]; then | |
| cp "$SRC" "$DEST/" | |
| echo "Copied $SRC -> $DEST/" | |
| else | |
| echo "Warning: $SRC not found in repo. Skipping." | |
| fi | |
| } | |
| cp_if_exists ".github/google5c656ab590a2ed69.html" | |
| cp_if_exists ".github/discord" | |
| - name: Deploy to CF | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ env.CF_API_TOK }} | |
| accountId: ${{ env.CF_ACC_ID }} | |
| command: pages deploy --project-name=mmkb | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| deploy-gh: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zip | |
| path: ./site | |
| - name: Unzip Writerside Output | |
| run: | | |
| ZIP_FILE="$(basename '${{ needs.build.outputs.zip_path }}')" | |
| DEST_DIR="./site/${{ needs.build.outputs.build_dir }}" | |
| echo "Unzipping $ZIP_FILE into $DEST_DIR" | |
| mkdir -p "$DEST_DIR" | |
| unzip "./site/$ZIP_FILE" -d "$DEST_DIR" | |
| - name: Upload Pages Artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| name: github-pages | |
| path: ./site/${{ needs.build.outputs.build_dir }} | |
| - name: Deploy to GH | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| deploy-algolia: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| env: | |
| ALGOLIA_APPLICATION_ID: ${{ secrets.ALG_APP_ID }} | |
| ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALG_ADM_API_KEY }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Algolia Indexes | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: algolia-zip | |
| path: ./algolia | |
| - name: Unzip Algolia Data | |
| run: | | |
| ZIP_NAME="$(basename '${{ needs.build.outputs.algolia_zip }}')" | |
| echo "Unzipping ./algolia/$ZIP_NAME into ./algolia" | |
| unzip "./algolia/$ZIP_NAME" -d ./algolia | |
| - name: Setup Algolia CLI | |
| uses: algolia/setup-algolia-cli@master | |
| - name: Publish Algolia Indexes | |
| run: | | |
| cd algolia | |
| for file in *.json; do | |
| echo "Importing $file into $ALGOLIA_INDEX_NAME" | |
| algolia objects import Index -F "$file" | |
| done |