typos #7
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 Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: barcoder-prod | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Assemble site | |
| env: | |
| CLIENT_ID: ${{ secrets.BARCODER_SPOTIFY_CLIENT_ID || vars.BARCODER_SPOTIFY_CLIENT_ID }} | |
| CLIENT_SECRET: ${{ secrets.BARCODER_SPOTIFY_SECRET_WEB || vars.BARCODER_SPOTIFY_SECRET_WEB }} | |
| run: | | |
| mkdir -p _site | |
| cp index.html app.js style.css favicon.svg _site/ | |
| python3 - <<'PY' | |
| import json, os | |
| from pathlib import Path | |
| client_id = os.environ.get('CLIENT_ID') or '' | |
| client_secret = os.environ.get('CLIENT_SECRET') or '' | |
| Path('_site/config.js').write_text( | |
| 'window.BARCODER = {\n' | |
| f'\tclientId: {json.dumps(client_id)},\n' | |
| f'\tclientSecret: {json.dumps(client_secret)},\n' | |
| '}\n' | |
| ) | |
| counter = ( | |
| '<script src=https://cdn.counter.dev/script.js ' | |
| 'data-id=4f8ae39e-3e03-4518-b3cd-2b44c8b60f93 ' | |
| 'data-utcoffset=4></script>\n' | |
| ) | |
| index = Path('_site/index.html') | |
| html = index.read_text() | |
| if '</body>' not in html: | |
| raise SystemExit('index.html missing </body>') | |
| if 'cdn.counter.dev/script.js' not in html: | |
| index.write_text(html.replace('</body>', counter + '</body>', 1)) | |
| PY | |
| - uses: actions/configure-pages@v5 | |
| - uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: _site | |
| - id: deployment | |
| uses: actions/deploy-pages@v4 |