Skip to content

Deploy to GitHub Pages #546

Deploy to GitHub Pages

Deploy to GitHub Pages #546

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify webhook URL
run: |
if [ -z "${{ secrets.DISCORD_WEBHOOK_URL }}" ]; then
echo "Error: DISCORD_WEBHOOK_URL is not set"
exit 1
fi
echo "DISCORD_WEBHOOK_URL is set"
- name: Inject webhook URL
env:
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
# Create the script tag with proper escaping and explicit var declaration
SCRIPT='<script>var DISCORD_WEBHOOK_URL = `'
SCRIPT+="$WEBHOOK_URL"
SCRIPT+='`; window.DISCORD_WEBHOOK_URL = DISCORD_WEBHOOK_URL;</script>'
# Insert after title tag and verify
perl -i -pe "s|</title>|\$&\n\t\t$SCRIPT|" index.html
echo "Verifying webhook URL injection..."
if ! grep -q "DISCORD_WEBHOOK_URL =" index.html; then
echo "Error: Failed to inject webhook URL"
exit 1
fi
echo "Successfully injected webhook URL"
# Show the modified section (URL hidden)
echo "Modified section (URL hidden):"
grep -A 1 -B 1 "DISCORD_WEBHOOK_URL" index.html | sed 's|`https://[^`]*`|[WEBHOOK_URL_HIDDEN]|'
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4