fetch-download-stats #66
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: fetch-download-stats | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 0 * * * | |
permissions: write-all | |
jobs: | |
fetch: | |
name: fetch-and-publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: install-deps | |
run: sudo apt-get install -y jq | |
- name: git-config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: checkout-new-branch | |
id: new_branch | |
run: | | |
new_branch="update-stats-$(date +%F)" | |
git checkout -b "${new_branch}" | |
echo "::set-output name=new_branch::${new_branch}" | |
- name: run-script | |
id: run_fetch_script | |
run: bin/fetch-download-stats.sh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: git-commit-and-push | |
run: | | |
git add public/plugins/* | |
git add public/plugins.json | |
git commit -m "Updated plugin stats automatically on $(date +%F)" | |
git push origin -u "${PR_HEAD_BRANCH}" | |
env: | |
PR_HEAD_BRANCH: ${{ steps.new_branch.outputs.new_branch }} | |
- name: create-and-merge-pr | |
run: | | |
set -e | |
pr_number="$(gh pr create --head "${PR_HEAD_BRANCH}" --base main \ | |
--title "Updated plugin stats automatically on $(date +%F)" \ | |
--body 'This is an automatic PR generated by Github Actions' \ | |
--label 'auto-fetch')" | |
gh pr merge "${pr_number}" -d -s --auto | |
env: | |
GITHUB_TOKEN: ${{ secrets.PR_PAT }} | |
PR_HEAD_BRANCH: ${{ steps.new_branch.outputs.new_branch }} |