Add contact form target #34
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 | |
| on: | |
| push: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Build and Deploy | |
| runs-on: ubicloud-standard-8 | |
| env: | |
| INDEXNOW_KEY: ${{ secrets.INDEXNOW_KEY }} | |
| steps: | |
| - name: Checkout this repo | |
| uses: actions/checkout@v4 | |
| with: | |
| path: source | |
| fetch-depth: 0 | |
| - name: Checkout Chobble Template | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: chobble-mirror/chobble-template | |
| ref: main | |
| path: template | |
| sparse-checkout-cone-mode: false | |
| sparse-checkout: | | |
| .eleventy.js | |
| package.json | |
| bun.lock | |
| bunfig.toml | |
| flake.nix | |
| flake.lock | |
| bin | |
| scripts | |
| packages | |
| src | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Merge repos | |
| run: bun source/scripts/ci-merge.js template source combined | |
| - name: Update site.json with secrets | |
| run: | | |
| sed -i \ | |
| 's/"formspark_id": null/"formspark_id": "${{ secrets.FORMSPARK_ID }}"/g' \ | |
| "combined/src/_data/config.json" | |
| sed -i \ | |
| 's/"botpoison_public_key": null/"botpoison_public_key": "${{ secrets.BOTPOISON_PUBLIC_KEY }}"/g' \ | |
| "combined/src/_data/config.json" | |
| - name: Restore cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| combined/node_modules | |
| combined/.image-cache | |
| key: ${{ runner.os }}-bun-${{ hashFiles('combined/bun.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Build with Bun | |
| env: | |
| GIT_DATES_REPO: ../source | |
| run: | | |
| cd combined | |
| bun install --frozen-lockfile | |
| bun scripts/eleventy-build.js | |
| mkdir -p ../_site | |
| mv _site/* ../_site/ | |
| - name: Write IndexNow key file | |
| if: github.ref == 'refs/heads/main' && env.INDEXNOW_KEY != '' | |
| run: echo "${{ secrets.INDEXNOW_KEY }}" > "_site/${{ secrets.INDEXNOW_KEY }}.txt" | |
| - name: Set deployment environment | |
| id: deployment_env | |
| run: | | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| echo "storage_zone_name=${{ secrets.BUNNY_PRODUCTION_STORAGE_ZONE_NAME }}" >> $GITHUB_OUTPUT | |
| echo "storage_zone_password=${{ secrets.BUNNY_PRODUCTION_STORAGE_ZONE_PASSWORD }}" >> $GITHUB_OUTPUT | |
| echo "pull_zone_id_deploy=${{ secrets.BUNNY_PRODUCTION_PULL_ZONE_ID }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "storage_zone_name=${{ secrets.BUNNY_STAGING_STORAGE_ZONE_NAME }}" >> $GITHUB_OUTPUT | |
| echo "storage_zone_password=${{ secrets.BUNNY_STAGING_STORAGE_ZONE_PASSWORD }}" >> $GITHUB_OUTPUT | |
| echo "pull_zone_id_deploy=${{ secrets.BUNNY_STAGING_PULL_ZONE_ID }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Deploy to Bunny | |
| uses: R-J-dev/bunny-deploy@v2.0.6 | |
| with: | |
| access-key: ${{ secrets.BUNNY_ACCESS_KEY }} | |
| directory-to-upload: _site | |
| storage-endpoint: "https://storage.bunnycdn.com" | |
| storage-zone-name: ${{ steps.deployment_env.outputs.storage_zone_name }} | |
| storage-zone-password: ${{ steps.deployment_env.outputs.storage_zone_password }} | |
| concurrency: "5" | |
| enable-delete-action: true | |
| enable-purge-pull-zone: true | |
| pull-zone-id: ${{ steps.deployment_env.outputs.pull_zone_id_deploy }} | |
| replication-timeout: "15000" | |
| - name: Get site URL | |
| id: site-url | |
| run: echo "url=$(jq -r '.url' combined/src/_data/site.json)" >> $GITHUB_OUTPUT | |
| - name: Submit to IndexNow | |
| if: github.ref == 'refs/heads/main' && env.INDEXNOW_KEY != '' | |
| uses: bojieyang/indexnow-action@v3 | |
| with: | |
| sitemap-location: "${{ steps.site-url.outputs.url }}/sitemap.xml" | |
| key: ${{ secrets.INDEXNOW_KEY }} | |
| notify-failure: | |
| name: Notify on Failure | |
| runs-on: ubicloud-standard-8 | |
| needs: [build] | |
| if: failure() | |
| steps: | |
| - name: Send failure notification | |
| uses: NiNiyas/ntfy-action@master | |
| with: | |
| url: 'https://ntfy.sh' | |
| topic: ${{ secrets.NTFY_TOPIC }} |