Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/actions/build-font/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ runs:
steps:
- name: Log in to GitHub Container Registry
if: inputs.push-image == 'true'
uses: docker/login-action@v3
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ env.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0

- name: Build (and optionally push) Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: xkcd-script/generator
load: true
Expand All @@ -44,11 +44,13 @@ runs:

- name: Check generated files match committed files
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
git diff --exit-code xkcd-script/font/ xkcd-script/samples/ || {
echo ""
echo "Generated files differ from committed files."
echo "Download the 'xkcd-script-font-${{ inputs.version }}' artifact from this run and commit the updated unversioned files (xkcd-script.{otf,ttf,woff,sfd} and the sample PNGs)."
echo "Download the 'xkcd-script-font-${VERSION}' artifact from this run and commit the updated unversioned files (xkcd-script.{otf,ttf,woff,sfd} and the sample PNGs)."
exit 1
}

Expand All @@ -60,17 +62,19 @@ runs:

- name: Generate release artifacts
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
rm -rf dist
docker run --rm -v "$PWD":/repo -w /repo ghcr.io/ipython/xkcd-font:fontbuilder \
python3 xkcd-script/generator/generate_release_artifacts.py \
--version "${{ inputs.version }}" \
--version "$VERSION" \
--font-dir xkcd-script/font \
--js xkcd-script/xkcd-mathjax3.js \
--out-dir dist

- name: Upload unversioned + release artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: xkcd-script-font-${{ inputs.version }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-font
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: $/.github/actions/build-font
with:
version: 0.0-dev
push-image: ${{ github.event_name == 'push' }}
18 changes: 12 additions & 6 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
Expand All @@ -22,28 +20,36 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pages: read # configure-pages reads the Pages site config
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false

- name: Assemble site
env:
REPO: ${{ github.repository }}
run: ./docs/build.sh

- uses: actions/configure-pages@v5
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0

- uses: actions/upload-pages-artifact@v3
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: build/html

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
13 changes: 9 additions & 4 deletions .github/workflows/preview-link.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Font preview link

on:
pull_request_target:
# pull_request_target is required so fork PRs get a writable commit status.
# This job never checks out or executes PR code; it only reads the head SHA
# and posts a status, so the usual pull_request_target risks do not apply.
pull_request_target: # zizmor: ignore[dangerous-triggers]
branches: [master]

jobs:
Expand All @@ -13,11 +16,13 @@ jobs:
- name: Post font preview link
env:
GH_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
REPO: ${{ github.repository }}
run: |
sha="${{ github.event.pull_request.head.sha }}"
font_url="https://raw.githubusercontent.com/${{ github.repository }}/${sha}/xkcd-script/font/xkcd-script.woff"
sha="$HEAD_SHA"
font_url="https://raw.githubusercontent.com/${REPO}/${sha}/xkcd-script/font/xkcd-script.woff"
encoded=$(python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "$font_url")
gh api "repos/${{ github.repository }}/statuses/${sha}" \
gh api "repos/${REPO}/statuses/${sha}" \
-f state=success \
-f target_url="https://ipython.org/xkcd-font/xkcd-script/?font=${encoded}" \
-f description="Click to preview the font from this PR" \
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: ${{ github.event.release.tag_name }}
persist-credentials: false

- name: Derive version from release tag
id: version
run: echo "value=${TAG#v}" >> "$GITHUB_OUTPUT"
env:
TAG: ${{ github.event.release.tag_name }}

- uses: ./.github/actions/build-font
- uses: $/.github/actions/build-font
with:
version: ${{ steps.version.outputs.value }}
push-image: 'true'
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: GitHub Actions Security Analysis with zizmor

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

permissions:
contents: read

jobs:
zizmor:
runs-on: ubuntu-latest
permissions:
contents: read
# Needed to upload the results to the code-scanning dashboard.
security-events: write
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Run zizmor
uses: zizmorcore/zizmor-action@85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e # v0.7.1
Loading