Skip to content

About

Generate afdian sponsors svg on github action

Topics

Resources

Code of conduct

Stars

9 stars

Watchers

0 watching

Forks

Repository files navigation

afdian-sponsor

Generate afdian sponsors svg on github action

Go Report Card GitHub release GitHub License FOSSA Status

Go CI Release


Demo

See https://github.com/Sn0wo2/Sn0wo2/blob/main/.github/workflows/sponsor.yml

Example

name: Sponsor

on:
  workflow_dispatch:

jobs:
  build-and-run:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Run ifdian-sponsor action
        uses: Sn0wo2/afdian-sponsor@v1
        with:
          # Optional(default values)
          version: latest
          cache: true
        env:
          # Required
          # Get User ID and API Token from https://ifdian.net/dashboard/dev
          # And add them to your github secrets(https://github.com/$your-user-name/$your-repo/settings/secrets/actions/new)
          AFDIAN_USER_ID: ${{ secrets.AFDIAN_USER_ID }}
          AFDIAN_API_TOKEN: ${{ secrets.AFDIAN_API_TOKEN }}

          # Optional(default values)
          AFDIAN_OUTPUT: ./afdian-sponsor.svg
          AFDIAN_TOTAL_SPONSORS: 100
          AFDIAN_AVATAR_SIZE: 100
          AFDIAN_MARGIN: 15
          AFDIAN_AVATARS_PER_ROW: 15
          # Google Fonts CSS2 family value, e.g. "Noto Sans SC:wght@100..900" (default) or "ZCOOL QingKe HuangYou"
          # When set, the action fetches the matching font itself and hands it to the binary via AFDIAN_FONT_FILE;
          AFDIAN_FONT_FAMILY: Noto Sans SC:wght@100..900
          AFDIAN_FONT_FILE: ./font.ttf
          AFDIAN_FONTSIZE_SCALE: 8
          AFDIAN_PADDINGX_SCALE: 2
          AFDIAN_PADDINGY_SCALE: 4
          AFDIAN_SORT: time

      - name: Upload generated SVG
        uses: actions/upload-artifact@v4
        with:
          name: afdian-sponsor-svg
          path: afdian-sponsor.svg

Fonts

The binary never fetches fonts at runtime. The default font (Noto Sans SC:wght@100..900) is fetched at build time (make font / go generate ./internal/font, implemented by scripts/font) and embedded. scripts/font/charset.txt defines the character subset (the 500 most common simplified Chinese characters plus ASCII, digits and punctuation, from linkary/top-used-chars, MIT), constrained by Google Fonts' ~700 character subset limit.

When AFDIAN_FONT_FAMILY is set, the action fetches the matching subset itself and passes it to the binary via AFDIAN_FONT_FILE; when unset, the binary uses its embedded font. Characters outside the subset fall back to the system font.


go-afdian-api


License

FOSSA Status

About

Generate afdian sponsors svg on github action

Topics

Resources

Code of conduct

Stars

9 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages