name: Publish to BurstPage on: workflow_dispatch: push: branches: [main] permissions: contents: read jobs: publish: if: github.ref == 'refs/heads/main' && (github.event_name == 'workflow_dispatch' || vars.BURSTPAGE_AUTO_PUBLISH == 'true') runs-on: ubuntu-latest timeout-minutes: 10 concurrency: group: burstpage-${{ vars.BURSTPAGE_SITE_ID }} cancel-in-progress: false steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false # For a framework project, add your build steps here. # The publishing step reads the finished output directory. - name: Publish finished files env: GH_TOKEN: ${{ github.token }} BURSTPAGE_TOKEN: ${{ secrets.BURSTPAGE_TOKEN }} BURSTPAGE_WORKSPACE_ID: ${{ vars.BURSTPAGE_WORKSPACE_ID }} BURSTPAGE_SITE_ID: ${{ vars.BURSTPAGE_SITE_ID }} BURSTPAGE_OUTPUT_DIR: ${{ vars.BURSTPAGE_OUTPUT_DIR }} BURSTPAGE_TARGET: ${{ vars.BURSTPAGE_TARGET }} run: | set -euo pipefail : "${BURSTPAGE_TOKEN:?Add the BURSTPAGE_TOKEN repository secret.}" : "${BURSTPAGE_WORKSPACE_ID:?Set BURSTPAGE_WORKSPACE_ID.}" : "${BURSTPAGE_SITE_ID:?Set BURSTPAGE_SITE_ID.}" : "${BURSTPAGE_OUTPUT_DIR:?Set BURSTPAGE_OUTPUT_DIR.}" : "${BURSTPAGE_TARGET:?Set BURSTPAGE_TARGET.}" if [[ "$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_REF_NAME" --jq .sha)" != "$GITHUB_SHA" ]]; then echo "A newer commit is on this branch. Skipping this deployment." exit 0 fi config="$(mktemp "$RUNNER_TEMP/burstpage.XXXXXX")" trap 'rm -f -- "$config"' EXIT python3 - "$config" <<'PYTHON' import json import os from pathlib import Path import sys output = Path(os.environ['BURSTPAGE_OUTPUT_DIR']).resolve() repo = Path(os.environ['GITHUB_WORKSPACE']).resolve() if not output.is_relative_to(repo) or output == repo or not (output/'index.html').is_file(): raise SystemExit('Choose a repository subdirectory that contains your finished index.html.') with open(sys.argv[1], 'w') as config: json.dump({ 'apiUrl': 'https://burstpage.com', 'workspaceId': os.environ['BURSTPAGE_WORKSPACE_ID'], 'token': os.environ['BURSTPAGE_TOKEN'], }, config) PYTHON unset BURSTPAGE_TOKEN GH_TOKEN python3 .github/burstpage-client.py --config "$config" deploy \ "$BURSTPAGE_SITE_ID" "$BURSTPAGE_OUTPUT_DIR" --target "$BURSTPAGE_TARGET" \ --key "github-$GITHUB_REPOSITORY_ID-$GITHUB_RUN_ID"