Skip to content

Commit

Permalink
Make repository reusable by other sponsorables, simplify browser usage (
Browse files Browse the repository at this point in the history
#51)

* Use github repo owner and variables for easier reuse
* Revert to python to avoid improper flags parsing
* Make sure UTF8 is used in files
* Use built-in Chrome in macOS
* Render sponsorable in use
  • Loading branch information
kzu authored Sep 10, 2024
1 parent 70a5280 commit 84e9861
Show file tree
Hide file tree
Showing 92 changed files with 26 additions and 31 deletions.
Binary file modified .github/avatars/4OTC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/AshleyMedway.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/BlauhausTechnology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/ChilliCream.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/Chris-Johnston.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/DarrenAtConexus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/Giorgi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/IxTechnologies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/Jonathan-Hickey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/Keflon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/KenBonny.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/KirillOsenkov.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/LosManos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/MFB-Technologies-Inc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/MariuszKogut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/MelbourneDeveloper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/MikeCodesDotNET.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/Mrxx99.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/SeanKilleen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/SimonCropp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/Tdue21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/agileworks-eu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/agocke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/akunzai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/angelobelchior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/avatars/aritchie.png
Binary file modified .github/avatars/arsdragonfly.png
Binary file modified .github/avatars/augustoproiete.png
Binary file modified .github/avatars/aws.png
Binary file modified .github/avatars/bitbonk.png
Binary file modified .github/avatars/bngv.png
Binary file modified .github/avatars/brooke-hamilton.png
Binary file modified .github/avatars/certifytheweb.png
Binary file modified .github/avatars/chiluap.png
Binary file modified .github/avatars/clarius.png
Binary file modified .github/avatars/danielrmay.png
Binary file modified .github/avatars/dannevesdantas.png
Binary file modified .github/avatars/dansiegel.png
Binary file modified .github/avatars/davidjenni.png
Binary file modified .github/avatars/davidpallmann.png
Binary file modified .github/avatars/davidpetric.png
Binary file modified .github/avatars/davkean.png
Binary file modified .github/avatars/decriptor.png
Binary file modified .github/avatars/dgnaegi.png
Binary file modified .github/avatars/drivenet.png
Binary file modified .github/avatars/eajhnsn1.png
Binary file modified .github/avatars/eeseewy.png
Binary file modified .github/avatars/ehonda.png
Binary file modified .github/avatars/garywoodfine.png
Binary file modified .github/avatars/georg-jung.png
Binary file modified .github/avatars/jakobt.png
Binary file modified .github/avatars/jeremysimmons.png
Binary file modified .github/avatars/jfoshee.png
Binary file modified .github/avatars/juanfranblanco.png
Binary file modified .github/avatars/kazo0.png
Binary file modified .github/avatars/kfrancis.png
Binary file modified .github/avatars/kristinnstefansson.png
Binary file modified .github/avatars/lavahot.png
Binary file modified .github/avatars/lucabriguglia.png
Binary file modified .github/avatars/mackayn.png
Binary file modified .github/avatars/mckhendry.png
Binary file modified .github/avatars/meisenring.png
Binary file modified .github/avatars/michaelstaib.png
Binary file modified .github/avatars/mrange.png
Binary file modified .github/avatars/newrelic.png
Binary file modified .github/avatars/nietras.png
Binary file modified .github/avatars/okyrylchuk.png
Binary file modified .github/avatars/pedrobsaila.png
Binary file modified .github/avatars/ploeh.png
Binary file modified .github/avatars/rbnswartz.png
Binary file modified .github/avatars/rcollette.png
Binary file modified .github/avatars/richlee.png
Binary file modified .github/avatars/sandrock.png
Binary file modified .github/avatars/seanalexander.png
Binary file modified .github/avatars/shahzadhuq.png
Binary file modified .github/avatars/sorahex.png
Binary file modified .github/avatars/tbolon.png
Binary file modified .github/avatars/tinohager.png
Binary file modified .github/avatars/tonyqus.png
Binary file modified .github/avatars/torutek-gh.png
Binary file modified .github/avatars/twenzel.png
Binary file modified .github/avatars/unoplatform.png
Binary file modified .github/avatars/v-limo.png
Binary file modified .github/avatars/vezel-dev.png
Binary file modified .github/avatars/voroninp.png
Binary file modified .github/avatars/wdolek.png
Binary file modified .github/avatars/wjgthb.png
Binary file modified .github/avatars/yrashk.png
21 changes: 13 additions & 8 deletions .github/workflows/sponsors.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Write-Organization {
</foreignObject>
</svg>";

$svg | Set-Content -Path ".github/avatars/$($node.login).svg";
$svg | Set-Content -Encoding UTF8 -Path ".github/avatars/$($node.login).svg";
write-host "=> $($node.login).svg" -ForegroundColor Green;
}

Expand All @@ -45,13 +45,21 @@ function Write-User {
</foreignObject>
</svg>";

$svg | Set-Content -Path ".github/avatars/$($node.login).svg";
$svg | Set-Content -Encoding UTF8 -Path ".github/avatars/$($node.login).svg";
write-host "=> $($node.login).svg" -ForegroundColor DarkGray;
}

gh auth status

$query = gh api graphql --paginate --jq '.data.organization.sponsorshipsAsMaintainer.nodes' -f owner='devlooped' -f query='
$sponsorable = $env:sponsorable

if ([string]::IsNullOrEmpty($sponsorable)) {
throw "Environment variable 'sponsorable' is required."
}

write-host "Sponsorable account: $sponsorable" -ForegroundColor Cyan

$query = gh api graphql --paginate --jq '.data.organization.sponsorshipsAsMaintainer.nodes' -f owner=$sponsorable -f query='
query ($owner: String!, $endCursor: String) {
organization(login: $owner) {
sponsorshipsAsMaintainer(first: 100, after: $endCursor, orderBy: {field: CREATED_AT, direction: ASC}, includePrivate: false) {
Expand Down Expand Up @@ -106,14 +114,11 @@ $gold | %{ gh api graphql --jq '.data.organization' -f login=$_ -f query='query(
$links = "";

foreach ($sponsor in $sponsors) {
$links += "[![$($sponsor.sponsorEntity.name)](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/$($sponsor.sponsorEntity.login).png `"$($sponsor.sponsorEntity.name)`")](https://github.com/$($sponsor.sponsorEntity.login))`n";
$links += "[![$($sponsor.sponsorEntity.name)](https://raw.githubusercontent.com/$sponsorable/sponsors/main/.github/avatars/$($sponsor.sponsorEntity.login).png `"$($sponsor.sponsorEntity.name)`")](https://github.com/$($sponsor.sponsorEntity.login))`n";
}

$links | Out-File ./sponsors.md -Force -Encoding UTF8

write-host "Using chrome from $env:chrome"

Push-Location .github/avatars
$flags = '--hide-scrollbars --default-background-color=00000000 --headless --disable-remote-debugging --no-sandbox'
Get-ChildItem *.svg | %{ html2image --css ../workflows/sponsors.css --html "$($_.Name)" --save "$($_.BaseName).png" --chrome_path "$env:chrome" --custom_flags $flags -v --size 39,39}
Get-ChildItem *.svg | %{ python ../workflows/sponsors.py "$($_.Name)" "$($_.BaseName).png" }
Pop-Location
10 changes: 4 additions & 6 deletions .github/workflows/sponsors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
import sys
from html2image import Html2Image

chrome = sys.argv[1]
# read entire contents of file in args[2] as input
with open(sys.argv[2], 'r') as file:
with open(sys.argv[1], 'r', encoding='utf-8') as file:
input = file.read()

output = sys.argv[3]
output = sys.argv[2]

hti = Html2Image(size=(38,38), browser_executable=chrome)
hti = Html2Image(size=(39,39), custom_flags=['--headless', '--hide-scrollbars', '--default-background-color=00000000', '--disable-remote-debugging', '--no-sandbox'])
hti.browser.print_command = True
hti.browser.flags = ['--hide-scrollbars', '--default-background-color=00000000', '--headless', '--disable-remote-debugging', '--no-sandbox'];

# specify css with zero margin and padding and transparent html background
css = '''
Expand All @@ -22,5 +20,5 @@
}
'''

print(f'{input} -> {output}')
print(f'{sys.argv[1]} -> {output}')
hti.screenshot(html_str=input, css_str=css, save_as=output)
21 changes: 4 additions & 17 deletions .github/workflows/sponsors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
name: sponsors
on:
workflow_dispatch:
inputs:
chrome:
# Lookup desired version at https://chromiumdash.appspot.com/releases?platform=Windows
# Then find the closest position to the Base Branch Position at
# https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/
description: Chrome Position
schedule:
- cron: "0 23 * * *"
push:
Expand All @@ -24,8 +18,8 @@ jobs:
- name: 🤖 defaults
uses: devlooped/actions-bot@v1
with:
name: ${{ secrets.BOT_NAME }}
email: ${{ secrets.BOT_EMAIL }}
name: ${{ vars.BOT_NAME || secrets.BOT_NAME }}
email: ${{ vars.BOT_EMAIL || secrets.BOT_EMAIL }}
gh_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -34,22 +28,15 @@ jobs:
with:
token: ${{ env.GH_TOKEN }}

- name: 🌐 chrome
uses: browser-actions/setup-chrome@v1
id: chrome
with:
chrome-version: ${{ github.event.inputs.chrome || vars.chrome || '1331469' }}
install-dependencies: true
install-chromedriver: true

- name: 🔽 html2image
run: pip install --force-reinstall -v html2image==2.0.5
run: pip install --force-reinstall -v html2image==2.0.3

- name: 💜 sponsors
shell: pwsh
run: ./.github/workflows/sponsors.ps1
env:
chrome: ${{ steps.chrome.outputs.chrome-path }}
sponsorable: ${{ github.repository_owner }}

- name: +Mᐁ includes
uses: devlooped/actions-include@v1
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The list can be included directly by using the [resolve file includes](https://g
action and pointing the include to the [sponsors.md](https://github.com/devlooped/sponsors/raw/main/sponsors.md) or
the convenient [footer.md](https://github.com/devlooped/sponsors/raw/main/footer.md) (as `raw` links).

To reuse this in your own fork, add a secret named `GH_TOKEN` that has permissions to query your sponsorships
(via the [GitHub CLI](https://cli.github.com)) and update files in your repository. The `BOT_NAME` and `BOT_EMAIL`
repo/org secrets or variables can be used to set the committer name and email.


<!-- include sponsors.md -->
[![Clarius Org](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/clarius.png "Clarius Org")](https://github.com/clarius)
[![Kirill Osenkov](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/KirillOsenkov.png "Kirill Osenkov")](https://github.com/KirillOsenkov)
Expand Down

0 comments on commit 84e9861

Please sign in to comment.