Skip to content

Show line endpoints in lines mode #13

Show line endpoints in lines mode

Show line endpoints in lines mode #13

Workflow file for this run

name: Publish
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
SITE_URL: https://rangoonmapper.khzaw.dev
permissions:
contents: read
packages: write
jobs:
verify:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Run tests
run: pnpm test:run
- name: Build
run: pnpm build
build-and-push:
needs: verify
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set timestamp
id: timestamp
run: echo "ts=$(date +%s)" >> "$GITHUB_OUTPUT"
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=raw,value=latest
type=raw,value=${{ steps.timestamp.outputs.ts }}-${{ github.sha }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Purge Cloudflare cache for update-critical files
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
SITE_URL: ${{ env.SITE_URL }}
run: |
set -euo pipefail
if [ -z "${CLOUDFLARE_API_TOKEN:-}" ] || [ -z "${CLOUDFLARE_ZONE_ID:-}" ]; then
echo "::notice::Skipping Cloudflare purge because CLOUDFLARE_API_TOKEN or CLOUDFLARE_ZONE_ID is not set."
exit 0
fi
response="$(
curl --silent --show-error \
-X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
-H "Content-Type: application/json" \
--data "{\"files\":[\"${SITE_URL}/\",\"${SITE_URL}/index.html\",\"${SITE_URL}/data/adjancencyList.json\",\"${SITE_URL}/data/route_shapes.json\",\"${SITE_URL}/data/stops_map.json\",\"${SITE_URL}/data/bus_services.json\",\"${SITE_URL}/data/unique_stops.json\"]}"
)"
if [ "$(echo "$response" | jq -r '.success // false')" != "true" ]; then
echo "::warning::Cloudflare cache purge failed; deploy will continue. Response: $(echo "$response" | jq -c '{errors, messages}')"
fi