-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (55 loc) · 2.34 KB
/
update_plugin_stats.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: update-plugin-stats
on:
schedule:
- cron: '1 0 * * *'
workflow_dispatch:
jobs:
update-plugin-stats:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- uses: actions/checkout@v2
- uses: geertvdc/setup-hub@master
- name: update-plugin-stats
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "yasasw"
git config --global user.email "[email protected]"
git pull
cd nodescriptsTS
npm install
cd src
cp ../../plugin_stats.json plugin_stats.json
cp -r ../../plugin_versions plugin_versions
npx ts-node updatePluginStats.ts
npx ts-node updateAuthorStats.ts
npx ts-node updatePluginVersionPlatforms.ts
cd ../../
cp nodescriptsTS/src/plugin_stats.json plugin_stats.json
cp nodescriptsTS/src/plugin_versions.json plugin_versions.json
cp nodescriptsTS/src/author_stats.json author_stats.json
rm -r plugin_versions
cp -r nodescriptsTS/src/plugin_versions plugin_versions
branchName=stat-update
commituser=Duet3D
git checkout -b $branchName
git add plugin_stats.json plugin_versions.json author_stats.json plugin_versions
git commit -m "Stat update - $(date +"%Y-%m-%d")"
git push -u origin $branchName
hub pull-request -m "[StatsUpdate]/$(date +"%Y-%m-%d")" --base $commituser:master --head $commituser:$branchName
merge-pr:
needs: update-plugin-stats
runs-on: ubuntu-latest
steps:
- name: merge-pr
run: |
url=$(curl \
-H "Accept: application/vnd.github+json" -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" https://api.github.com/repos/Duet3D/PluginRepository/pulls \
| jq '.[] | select(.title | startswith("[StatsUpdate]"))' | jq ."url" | sed 's/"//g')/merge
echo $url
echo $(curl -X PUT -H "Accept: application/vnd.github+json" -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" $url | jq ) > merge_response.json
cat merge_response.json | jq
merged=$(cat merge_response.json | jq ."merged" | sed 's/"//g')
if [[ "$merged" = true ]]; then exit 0; else exit 1; fi