Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ name: Deploy to GitHub Pages
on:
push:
branches: [main, master]
pull_request:
schedule:
- cron: "0 6 * * *" # Rebuild daily at 6am UTC
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.ref) || 'pages' }}
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-24.04
outputs:
sitemap_urls: ${{ steps.sitemap.outputs.urls }}
steps:
- uses: actions/checkout@v6

Expand All @@ -35,15 +36,21 @@ jobs:
- name: Install npm dependencies
run: npm ci

- name: Setup Pages
uses: actions/configure-pages@v6

- name: Build site
run: bundle exec rake deploy
env:
BRIDGETOWN_ENV: production

- name: Run specs
run: bundle exec rake test

# Read from the fresh build, not the live site (Pages' CDN can serve a stale sitemap after deploy)
- name: Collect sitemap URLs for IndexNow
id: sitemap
run: echo "urls=$(bundle exec ruby -rrexml/document -rjson -e 'puts REXML::Document.new(File.read("output/sitemap.xml")).get_elements("urlset/url/loc").map(&:text).to_json')" >> "$GITHUB_OUTPUT"

- name: Upload artifact
if: github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@v5
with:
path: output
Expand All @@ -54,7 +61,28 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-24.04
needs: build
if: github.event_name != 'pull_request'
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5

# Runs only after Pages reports a successful deploy. URLs come from the build job's sitemap.
# ponytail: pings every sitemap URL on each deploy (incl. daily cron); diff against the previous sitemap if IndexNow starts throttling
- name: Ping IndexNow
continue-on-error: true
env:
INDEXNOW_KEY: d3edebe3-2774-4cd0-b3aa-780a8587c0a6
SITE: https://www.rakefire.io
URLS: ${{ needs.build.outputs.sitemap_urls }}
run: |
set -o pipefail
if [ -z "$URLS" ] || [ "$URLS" = "[]" ]; then echo "::warning::No sitemap URLs from build; skipping IndexNow"; exit 0; fi
echo "Submitting: $URLS"
jq -nc --arg key "$INDEXNOW_KEY" --arg site "$SITE" --argjson urls "$URLS" \
'{host: ($site | sub("https://"; "")), key: $key, keyLocation: "\($site)/\($key).txt", urlList: $urls}' \
| curl -fsS -w 'IndexNow HTTP %{http_code}\n' -X POST https://api.indexnow.org/indexnow \
-H 'Content-Type: application/json; charset=utf-8' --data-binary @-
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem "bridgetown", "~> 2.1"
gem "bridgetown", "~> 2.2"
gem "bridgetown-feed", "~> 4.0"
gem "bridgetown-sitemap", "~> 3.0"
gem "bridgetown-seo-tag", "~> 7.0"
Expand All @@ -18,3 +18,9 @@ gem "htmlcompressor", "~> 0.4"
group :test, :development do
gem "puma", "~> 7.2"
end

group :test do
gem "minitest"
gem "rack-test"
gem "nokolexbor"
end
Loading