update Actions workflow #13
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: 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: Debug environment | |
| run: | | |
| echo "Current directory contents:" | |
| ls -la | |
| echo "Checking if webhook URL is set:" | |
| if [ -n "${{ secrets.DISCORD_WEBHOOK_URL }}" ]; then | |
| echo "Webhook URL is set" | |
| else | |
| echo "Webhook URL is NOT set" | |
| exit 1 | |
| fi | |
| - name: Inject webhook URL | |
| env: | |
| WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| run: | | |
| echo "Injecting webhook URL into index.html..." | |
| echo "Before injection (showing relevant line):" | |
| grep -n "let webhookUrl = null;" index.html || echo "Pattern not found" | |
| # Create a temporary file with the replacement | |
| awk -v url="$WEBHOOK_URL" ' | |
| { | |
| if ($0 ~ /let webhookUrl = null;/) { | |
| print " const webhookUrl = \"" url "\"; // Injected during build" | |
| } else { | |
| print $0 | |
| } | |
| }' index.html > index.html.tmp | |
| # Replace the original file | |
| mv index.html.tmp index.html | |
| echo "After injection (showing relevant line, URL hidden):" | |
| grep -n "webhookUrl = " index.html | sed 's|https://[^"]*|[WEBHOOK_URL_HIDDEN]|' | |
| echo "Verifying file was modified:" | |
| if grep -q "Injected during build" index.html; then | |
| echo "Webhook URL successfully injected" | |
| else | |
| echo "Failed to inject webhook URL" | |
| exit 1 | |
| fi | |
| - 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 |