update-plugin-stats #890
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |