Skip to content

Commit 4745ffc

Browse files
authored
Update main.yml
1 parent 1de2a6d commit 4745ffc

1 file changed

Lines changed: 3 additions & 72 deletions

File tree

.github/workflows/main.yml

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: 🔄 Update README with Onefetch
2-
32
on:
43
push:
54
branches:
@@ -8,82 +7,14 @@ on:
87
schedule:
98
- cron: "0 0 * * 0"
109
workflow_dispatch:
11-
1210
permissions:
1311
contents: write
14-
1512
jobs:
1613
update-readme:
1714
name: Gerar Onefetch e atualizar README
1815
runs-on: ubuntu-latest
19-
2016
steps:
21-
- name: 📥 Checkout do repositório
22-
uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
26-
- name: 🦀 Instalar Onefetch
27-
run: |
28-
VERSION=$(curl -sI https://github.com/o2sh/onefetch/releases/latest \
29-
| grep -i location | sed 's|.*/tag/||' | tr -d '[:space:]')
30-
echo "Versão detectada: $VERSION"
31-
curl -sL "https://github.com/o2sh/onefetch/releases/download/${VERSION}/onefetch_amd64.deb" \
32-
-o onefetch.deb
33-
sudo dpkg -i onefetch.deb
34-
onefetch --version
35-
36-
- name: 🧊 Instalar ansisvg
37-
run: |
38-
curl -sL "https://github.com/nicowillis/ansisvg/releases/latest/download/ansisvg-linux-amd64" \
39-
-o ansisvg
40-
chmod +x ansisvg
41-
sudo mv ansisvg /usr/local/bin/ansisvg
42-
43-
- name: 🎨 Gerar SVG com onefetch + console2svg
44-
run: |
45-
npm install -g console2svg
46-
console2svg -o onefetch.svg -- onefetch -d pending
47-
# Adiciona bordas arredondadas ao rect de fundo
48-
sed -i 's/\(<rect[^>]*\)\/>/\1 rx="12" ry="12"\/>/' onefetch.svg
49-
50-
- name: 📝 Atualizar README.md
51-
run: |
52-
python3 << 'EOF'
53-
import re
54-
try:
55-
with open("README.md", "r", encoding="utf-8") as f:
56-
readme = f.read()
57-
except FileNotFoundError:
58-
readme = ""
59-
60-
new_block = "<!-- ONEFETCH_START -->\n![Onefetch](./onefetch.svg)\n<!-- ONEFETCH_END -->"
61-
pattern = r"<!-- ONEFETCH_START -->.*?<!-- ONEFETCH_END -->"
62-
63-
if re.search(pattern, readme, re.DOTALL):
64-
updated = re.sub(pattern, new_block, readme, flags=re.DOTALL)
65-
else:
66-
updated = readme.rstrip() + "\n\n" + new_block + "\n"
67-
68-
with open("README.md", "w", encoding="utf-8") as f:
69-
f.write(updated)
70-
print("README.md atualizado!")
71-
EOF
72-
73-
- name: 🔍 Verificar mudanças
74-
id: check_changes
75-
run: |
76-
if git diff --quiet README.md onefetch.svg; then
77-
echo "changed=false" >> $GITHUB_OUTPUT
78-
else
79-
echo "changed=true" >> $GITHUB_OUTPUT
80-
fi
17+
- uses: actions/checkout@v4
8118

82-
- name: 💾 Commit e Push
83-
if: steps.check_changes.outputs.changed == 'true'
84-
run: |
85-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
86-
git config --local user.name "github-actions[bot]"
87-
git add README.md onefetch.svg
88-
git commit -m "docs: atualiza estatísticas do repo via onefetch [skip ci]"
89-
git push
19+
- name: Fetch-Docs-CLI
20+
uses: miojo-dev/Fetch-Docs-CLI@v1.0.2-language_fix

0 commit comments

Comments
 (0)