Merge pull request #16 from MrAlders0n/copilot/fix-github-pages-deplo… #11
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: Create config.js with API key from secrets | |
| env: | |
| API_KEY: ${{ secrets.MESHMAPPER_API_KEY }} | |
| run: | | |
| if [ -z "$API_KEY" ]; then | |
| echo "ERROR: MESHMAPPER_API_KEY secret is not set!" | |
| exit 1 | |
| fi | |
| { | |
| echo "// MeshMapper API Configuration" | |
| echo "// This file is auto-generated during deployment from GitHub Secrets" | |
| echo "// Build timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" | |
| node -e "console.log('window.MESHMAPPER_API_KEY = ' + JSON.stringify(process.env.API_KEY) + ';')" | |
| } > content/config.js | |
| echo "Generated config.js content:" | |
| cat content/config.js | |
| echo "API key length: ${#API_KEY}" | |
| - name: Add cache-busting to config.js script tag | |
| run: | | |
| BUILD_ID=$(date +%s) | |
| sed -i "s|<script src=\"content/config.js\"|<script src=\"content/config.js?v=${BUILD_ID}\"|g" index.html | |
| echo "Updated index.html with cache-busting parameter: v=${BUILD_ID}" | |
| grep "config.js" index.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Verify config.js before upload | |
| run: | | |
| echo "Verifying config.js content before artifact upload:" | |
| cat content/config.js | |
| if grep -q "YOUR_API_KEY_HERE" content/config.js; then | |
| echo "ERROR: config.js still contains placeholder!" | |
| exit 1 | |
| fi | |
| echo "✓ config.js contains actual API key" | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: '.' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |