|
1 | | -name: Skripte ausführen und README aktualisieren |
| 1 | +name: 🗓️ Update Python Day Counter |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [main] |
| 6 | + schedule: |
| 7 | + - cron: "0 8 * * *" |
6 | 8 | workflow_dispatch: |
7 | 9 |
|
8 | 10 | jobs: |
9 | | - run-scripts: |
| 11 | + update-day-counter: |
10 | 12 | runs-on: ubuntu-latest |
11 | 13 |
|
12 | 14 | steps: |
13 | | - - name: Checkout repository |
| 15 | + - name: 📥 Checkout repository |
14 | 16 | uses: actions/checkout@v3 |
15 | 17 |
|
16 | | - - name: Setup Python |
| 18 | + - name: 🐍 Set up Python |
17 | 19 | uses: actions/setup-python@v4 |
18 | 20 | with: |
19 | 21 | python-version: '3.12' |
20 | 22 |
|
21 | | - - name: Run Herztext.py |
22 | | - working-directory: ./simple_py_program |
23 | | - run: python Herztext.py |
24 | | - |
25 | | - - name: Run Sanduhr.py |
26 | | - working-directory: ./simple_py_program |
27 | | - run: python Sanduhr.py |
28 | | - |
29 | | - - name: Run day_counter.py |
| 23 | + - name: ▶️ Run day_counter.py |
30 | 24 | working-directory: ./simple_py_program |
31 | 25 | run: python day_counter.py |
32 | 26 |
|
33 | | - - name: Insert Outputs into README |
34 | | - run: | |
35 | | - declare -A outputs |
36 | | - outputs[HERZTEXT]="output_Herztext.md" |
37 | | - outputs[SANDUHR]="output_Sanduhr.md" |
38 | | -
|
39 | | - # Insert outputs into README file |
40 | | - for key in "${!outputs[@]}"; do |
41 | | - start="<!-- ${key}_OUTPUT_START -->" |
42 | | - end="<!-- ${key}_OUTPUT_END -->" |
43 | | - content=$(cat "${outputs[$key]}") |
44 | | - awk -v s="$start" -v e="$end" -v r="$content" ' |
45 | | - BEGIN {print_section=1} |
46 | | - $0 ~ s {print; print r; print_section=0; next} |
47 | | - $0 ~ e {print_section=1} |
48 | | - print_section==1 {print} |
49 | | - ' README.md > tmp && mv tmp README.md |
50 | | - done |
51 | | -
|
52 | | - - name: Commit changes and push |
| 27 | + - name: 📤 Commit and push if changed |
53 | 28 | run: | |
54 | 29 | git config --global user.name "1501henify" |
55 | 30 | git config --global user.email "[email protected]" |
56 | | - git add README.md |
57 | | - git commit -m "README updated with latest outputs and day counter" |
| 31 | + git add ../README.md |
| 32 | + git diff --cached --quiet || git commit -m "🔁 Updated day counter in README" |
58 | 33 | git push |
59 | 34 | continue-on-error: true |
0 commit comments