-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yusef Almamari
committed
Sep 5, 2024
1 parent
15adbd0
commit fe44011
Showing
2 changed files
with
27 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,34 @@ | ||
name: Create Badge | ||
name: BYOB | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
schedule: | ||
- cron: "*/5 * * * *" | ||
|
||
jobs: | ||
create-badge: | ||
badge_job: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
- name: Bring Your Own Badge | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Install dependencies | ||
NAME: contributions-welcome | ||
LABEL: "Contributions Welcome" | ||
ICON: "github" | ||
STATUS: "Contributions welcome" | ||
COLOR: green | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Read LICENSE file | ||
id: license | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install shields.io | ||
- name: Generate badge | ||
run: | | ||
import os | ||
from shields.io import Badge | ||
# Get license content | ||
with open('.gitattributes') as f: | ||
license_content = f.read() | ||
# Create static badge | ||
static_badge = Badge( | ||
label="Contributions welcome", | ||
message="Contributions welcome!", | ||
color="green" | ||
) | ||
echo "::set-env name=LICENSE_CONTENT::$(cat ${GITHUB_WORKSPACE}/LICENSE)" | ||
# Create dynamic badge | ||
dynamic_badge = Badge( | ||
label="License", | ||
message=license_content, | ||
color="blue" | ||
) | ||
# Save badges as SVG files | ||
static_badge.save("static_badge.svg") | ||
dynamic_badge.save("dynamic_badge.svg") | ||
- name: Update README.md | ||
run: | | ||
echo "# License\n\n$(cat .gitattributes)" >> README.md | ||
echo "\n[![Static Badge](static_badge.svg)](https://github.com/discontinuedlabs/citeease/blob/main/static_badge.svg)" >> README.md | ||
echo "\n[![Dynamic Badge](dynamic_badge.svg)](https://github.com/discontinuedlabs/citeease/blob/main/dynamic_badge.svg)" >> README.md | ||
- name: Commit changes | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add . | ||
git commit -m "Update README with badge" | ||
git push | ||
- name: Bring Your Own Badge | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: license | ||
LABEL: "License" | ||
ICON: "license" | ||
STATUS: ${{ env.LICENSE_CONTENT | truncate:50 }} | ||
COLOR: blue | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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