Generate Sponsors README #70
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate Sponsors README | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: 0 4 * * * | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout 🛎️ | |
| uses: actions/checkout@v6 | |
| - name: Generate GitHub Sponsors 💖 | |
| uses: JamesIves/github-sponsors-readme-action@v1 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| file: 'README.md' | |
| organization: true | |
| template: '<a href="https://github.com/{{{ login }}}"><img src="{{{ avatarUrl }}}" width="80px" alt="User avatar: {{{ login }}}" /></a> ' | |
| - name: Generate Liberapay Patrons 💸 | |
| run: | | |
| set -euo pipefail | |
| csv_url="https://liberapay.com/hcloud-k8s/patrons/public.csv" | |
| patrons_html="$( | |
| curl -fsSL "$csv_url" \ | |
| | perl -MText::ParseWords -ne ' | |
| chomp; | |
| my @fields = Text::ParseWords::parse_line(",", 0, $_); | |
| for (@fields) { s/\r$//; } | |
| if ($. == 1) { | |
| for my $i (0 .. $#fields) { | |
| $col{$fields[$i]} = $i; | |
| } | |
| next; | |
| } | |
| my $username_idx = $col{"patron_username"}; | |
| my $avatar_idx = $col{"patron_avatar_url"}; | |
| next unless defined $username_idx; | |
| my $username = $fields[$username_idx] // ""; | |
| my $avatar = defined $avatar_idx ? ($fields[$avatar_idx] // "") : ""; | |
| next if $username eq ""; | |
| if ($avatar eq "") { | |
| $avatar = "https://liberapay.com/assets/liberapay/icon-v2_black.200.png"; | |
| } | |
| print qq{<a href="https://liberapay.com/$username"><img src="$avatar" width="80" alt="$username" /></a> }; | |
| ' | |
| )" | |
| escaped_patrons_html="${patrons_html//\\/\\\\}" | |
| escaped_patrons_html="${escaped_patrons_html//\$/\\$}" | |
| perl -0777 -i -pe "s|<!-- patrons -->.*?<!-- patrons -->|<!-- patrons -->${escaped_patrons_html}<!-- patrons -->|s" README.md | |
| - name: Deploy to GitHub Pages 🚀 | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: main | |
| folder: '.' |