Skip to content

Commit

Permalink
Add workflow to update sponsors to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
huxingyi committed Dec 17, 2022
1 parent 7ca1824 commit bc36bb5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/update-sponsors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: update-sponsors

on:
schedule:
- cron: "0 0 * * *" # Run every day at midnight
branches:
- master

jobs:
update-sponsors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Fetch sponsors
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const query = `
query {
user(login: "huxingyi") {
sponsorshipsAsMaintainer(first: 100) {
totalCount
nodes {
id
createdAt
tier {
name
}
sponsor {
login
avatarUrl
}
}
}
}
}
`;
const response = await github.graphql(query);
let html = '';
for (const node of response.data.user.sponsorshipsAsMaintainer.nodes) {
html += '<a href="' + node.sponsor.url + '" title="' + node.sponsor.login + (node.sponsor.name ? (' (' + node.sponsor.name + ')') : '') + '" target=_blank><image src="' + node.sponsor.avatarUrl + '" alt="@' + node.sponsor.login + '" width="35" height="35" style="border-radius: 17px;" /></a>\n';
}
if ('' !== html) {
html = '## Sponsors \n\n' + html + '\n _The list shown represent active sponsors on GitHub and a full list can be viewed at [SUPPORTERS](https://github.com/huxingyi/dust3d/blob/master/SUPPORTERS)._';
}
require('fs').writeFileSync('SPONSORS.md', html);
- name: Replace content in README.md
run: |
# Read the contents of README.md into a variable
fileContents=$(cat README.md)
# Replace the content between the markers with the contents of SPONSORS.md
fileContents=$(echo "${fileContents}" | sed -e '/<!-- Sponsors begin -->/,/<!-- Sponsors end -->/{r SPONSORS.md; d}')
# Write the modified contents back to README.md
echo "${fileContents}" > README.md
- name: Upload README.md
run: |
# Check if README.md has changed
if git diff --name-only HEAD | grep -q "README.md"; then
# Stage the updated README.md file
git add README.md
# Commit the changes
git commit -m "Update sponsors"
# Push the commit to the master branch
git push origin HEAD
fi
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ These instructions will get you a copy of the Dust3D up and running on your loca

In order to build and run Dust3D, you will need the following software and tools:

- [Qt](https://www.qt.io/)
- Qt
- Visual Studio 2019 (Windows only)
- GCC (Linux only)

#### Windows

1. Download and install the [Qt Online Installer](https://www.qt.io/download)
1. Download and install the `Qt Online Installer`
2. Run the installer and choose the Qt archives you want to install (required: qtbase, qtsvg)
3. Install Visual Studio 2019

Expand Down Expand Up @@ -51,4 +51,8 @@ git clone https://github.com/huxingyi/dust3d.git

## License

Dust3D is licensed under the MIT License - see the [LICENSE](https://github.com/huxingyi/dust3d/blob/master/LICENSE) file for details.
Dust3D is licensed under the MIT License - see the [LICENSE](https://github.com/huxingyi/dust3d/blob/master/LICENSE) file for details.

<!-- Sponsors begin -->

<!-- Sponsors end -->

0 comments on commit bc36bb5

Please sign in to comment.