Skip to content

Create CNAME

Create CNAME #2

Workflow file for this run

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:
# Prefer Secrets; fall back to Variables (current setup).
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 ''
if not client_id or not client_secret:
raise SystemExit('Missing BARCODER_SPOTIFY_CLIENT_ID or BARCODER_SPOTIFY_SECRET_WEB in barcoder-prod')
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>')
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