|
8 | 8 | runs-on: ubuntu-22.04 |
9 | 9 |
|
10 | 10 | steps: |
11 | | - # Step 1: Checkout repository |
12 | 11 | - name: Checkout repository |
13 | 12 | uses: actions/checkout@v3 |
14 | 13 | with: |
15 | 14 | fetch-depth: 0 |
16 | 15 |
|
17 | | - # Step 2: Fetch badges.json content from gh-pages branch without tracking it |
18 | 16 | - name: Fetch badges.json from gh-pages branch |
19 | 17 | run: | |
20 | 18 | git fetch origin gh-pages |
21 | 19 | git show origin/gh-pages:badges.json > badges.json |
22 | 20 | echo "::notice::Fetched badges.json from gh-pages branch." |
23 | 21 |
|
24 | | - # Step 3: Parse badges.json and save artifact |
25 | 22 | - name: Parse badges.json and save artifact |
26 | 23 | run: | |
27 | 24 | node parse-badges.js |
28 | 25 | echo "::notice::Parsed badges.json and saved artifact." |
29 | 26 |
|
30 | | - # Step 4: Remove badges.json after parsing |
31 | 27 | - name: Clean up badges.json |
32 | 28 | run: | |
33 | 29 | rm -f badges.json |
34 | 30 | echo "::notice::Removed badges.json after parsing." |
35 | 31 |
|
36 | | - # Step 5: Upload parsed badges artifact |
37 | 32 | - name: Upload parsed badges artifact |
38 | 33 | uses: actions/upload-artifact@v4 |
39 | 34 | with: |
40 | 35 | name: parsed-badges |
41 | 36 | path: parsed-badges.json |
42 | 37 |
|
43 | | - # Step 6: Download parsed badges artifact |
44 | 38 | - name: Download parsed badges artifact |
45 | 39 | uses: actions/download-artifact@v4 |
46 | 40 | with: |
47 | 41 | name: parsed-badges |
48 | 42 |
|
49 | | - # Step 7: Update README if necessary |
50 | 43 | - name: Update README if changes are found |
51 | 44 | id: update-readme |
52 | 45 | run: | |
53 | 46 | node update-readme.js parsed-badges.json |
54 | 47 | if [ $? -eq 0 ]; then |
55 | | - echo "::set-output name=changes-found::true" |
56 | 48 | echo "changes-found=true" >> $GITHUB_ENV |
57 | 49 | else |
58 | | - echo "::set-output name=changes-found::false" |
59 | 50 | echo "changes-found=false" >> $GITHUB_ENV |
60 | 51 | fi |
61 | 52 | echo "::notice::Checked and updated README if changes were found." |
62 | 53 |
|
63 | | - # Step 8: Commit changes and create a new branch (only if changes were found) |
64 | 54 | - name: Commit changes and create a new branch |
65 | 55 | if: env.changes-found == 'true' |
66 | 56 | run: | |
|
70 | 60 | echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV |
71 | 61 | echo "$BRANCH_NAME" > branch-name.txt |
72 | 62 | git checkout -b $BRANCH_NAME |
73 | | - git add README.md # Explicitly add only README.md |
| 63 | + git add README.md |
74 | 64 | git commit -m "Update README with latest download URLs" |
75 | 65 | git push origin HEAD |
76 | 66 | echo "::notice::Changes committed and branch pushed." |
|
85 | 75 | create-pr: |
86 | 76 | runs-on: ubuntu-22.04 |
87 | 77 | needs: check-and-update-readme |
88 | | - if: needs.check-and-update-readme.outputs['changes-found'] == 'true' |
| 78 | + if: always() && env.changes-found == 'true' |
89 | 79 | steps: |
90 | 80 | - name: Download branch name artifact |
91 | 81 | uses: actions/download-artifact@v4 |
|
0 commit comments