test byob.yml #3
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
name: Create Badge | |
on: | |
push: | |
branches: [main] | |
jobs: | |
create-badge: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
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" | |
) | |
# 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 |