|
1 | 1 | name: Update monkeytype theme json list |
2 | 2 |
|
3 | 3 | on: |
4 | | - schedule: |
5 | | - - cron: '0 */24 * * *' |
6 | | - workflow_dispatch: |
| 4 | + schedule: |
| 5 | + - cron: "0 */24 * * *" |
| 6 | + workflow_dispatch: |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - make-request: |
10 | | - runs-on: ubuntu-latest |
11 | | - steps: |
12 | | - - name: Checkout code |
13 | | - uses: actions/checkout@v4 |
14 | | - |
15 | | - - name: Set up Node.js |
16 | | - uses: actions/setup-node@v3 |
17 | | - with: |
18 | | - node-version: '16.x' |
19 | | - |
20 | | - - name: Download theme json file from monkeytype |
21 | | - run: wget --timeout=180 --tries=3 --waitretry=10 --output-document=theme/themes.json https://monkeytype-readme.zeabur.app/mr-command/theme |
22 | | - timeout-minutes: 10 |
23 | | - |
24 | | - - name: Format JSON data |
25 | | - run: | |
26 | | - python3 -c 'import json; data = json.load(open("theme/themes.json")); json.dump(data, open("theme/themes.json", "w"), indent=2)' |
27 | | - |
28 | | - - name: Print json file contents |
29 | | - run: cat theme/themes.json |
30 | | - |
31 | | - - name: Update theme list |
32 | | - uses: actions/github-script@v6 |
33 | | - with: |
34 | | - script: | |
35 | | - const fs = require('fs'); |
36 | | - let monkeytypeThemesJson = fs.readFileSync('theme/themes.json'); |
37 | | - const filePath = '${{ github.workspace }}/theme/themes.json'; |
38 | | - fs.writeFileSync(filePath, monkeytypeThemesJson); |
39 | | - |
40 | | - - name: Print updated theme contents |
41 | | - run: | |
42 | | - cat theme/themes.json |
43 | | - |
44 | | - - name: Configure git |
45 | | - run: | |
46 | | - git config --global user.name "ridemountainpig" |
47 | | - git config --global user.email "lin0905580802@gmail.com" |
48 | | - |
49 | | - - name: Commit and push changes |
50 | | - run: | |
51 | | - if git diff-index --quiet HEAD --; then |
52 | | - echo "No changes detected." |
53 | | - else |
54 | | - git add . |
55 | | - git commit -m "feat: update themes json list" |
56 | | - fi |
57 | | - continue-on-error: true |
58 | | - |
59 | | - - name: Push changes |
60 | | - uses: ad-m/github-push-action@master |
61 | | - with: |
62 | | - branch: master |
63 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
| 9 | + make-request: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Set up Node.js |
| 16 | + uses: actions/setup-node@v3 |
| 17 | + with: |
| 18 | + node-version: "16.x" |
| 19 | + |
| 20 | + - name: Download theme json file from monkeytype |
| 21 | + run: wget --timeout=180 --tries=3 --waitretry=10 --output-document=theme/themes.json https://monkeytype-readme.zeabur.app/mr-command/theme |
| 22 | + timeout-minutes: 10 |
| 23 | + |
| 24 | + - name: Format JSON data |
| 25 | + run: | |
| 26 | + python3 -c 'import json; data = json.load(open("theme/themes.json")); json.dump(data, open("theme/themes.json", "w"), indent=2)' |
| 27 | +
|
| 28 | + - name: Print json file contents |
| 29 | + run: cat theme/themes.json |
| 30 | + |
| 31 | + - name: Update theme list |
| 32 | + uses: actions/github-script@v6 |
| 33 | + with: |
| 34 | + script: | |
| 35 | + const fs = require('fs'); |
| 36 | + let monkeytypeThemesJson = fs.readFileSync('theme/themes.json'); |
| 37 | + const filePath = '${{ github.workspace }}/theme/themes.json'; |
| 38 | + fs.writeFileSync(filePath, monkeytypeThemesJson); |
| 39 | +
|
| 40 | + - name: Print updated theme contents |
| 41 | + run: | |
| 42 | + cat theme/themes.json |
| 43 | +
|
| 44 | + - name: Configure git |
| 45 | + run: | |
| 46 | + git config --global user.name "ridemountainpig" |
| 47 | + git config --global user.email "lin0905580802@gmail.com" |
| 48 | +
|
| 49 | + - name: Commit and push changes |
| 50 | + run: | |
| 51 | + if git diff-index --quiet HEAD --; then |
| 52 | + echo "No changes detected." |
| 53 | + else |
| 54 | + git add . |
| 55 | + git commit -m "feat: update themes json list" |
| 56 | + fi |
| 57 | + continue-on-error: true |
| 58 | + |
| 59 | + - name: Push changes |
| 60 | + uses: ad-m/github-push-action@master |
| 61 | + with: |
| 62 | + branch: master |
| 63 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments