add node step #15
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: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - 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" | |
| # Use Node.js script to inject the webhook URL | |
| node scripts/inject-webhook.js "$WEBHOOK_URL" | |
| 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 by GitHub Actions" index.html; then | |
| echo "Webhook URL successfully injected" | |
| echo "Number of lines containing webhookUrl:" | |
| grep -c "webhookUrl" index.html | |
| 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 |