store_art_stats #146
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: store_art_stats | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: '1 0 14 * *' | |
- cron: '1 0 30 * *' | |
jobs: | |
test-curl-action: | |
name: "Perform REST API" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: get views | |
run: | | |
curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PYSOFTK_VIEWS }}" --request GET https://api.github.com/repos/alejandrosantanabonilla/pysoftk/traffic/views -o views.json | |
- name: get clones | |
run: | | |
curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PYSOFTK_VIEWS }}" --request GET https://api.github.com/repos/alejandrosantanabonilla/pysoftk/traffic/clones -o clones.json | |
- name: get referrals | |
run: | | |
curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PYSOFTK_VIEWS }}" --request GET https://api.github.com/repos/alejandrosantanabonilla/pysoftk/traffic/popular/referrers -o referrers.json | |
- name: get paths | |
run: | | |
curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PYSOFTK_VIEWS }}" --request GET https://api.github.com/repos/alejandrosantanabonilla/pysoftk/traffic/popular/paths -o paths.json | |
- name: Generate artifact name | |
id: generate-name | |
run: | | |
echo "::set-output name=artifact::${{ github.event.repository.name }}.${{ github.ref_name }}.${{ github.run_id }}.zip" | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.generate-name.outputs.artifact }} | |
path: ./*.json | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ steps.generate-name.outputs.artifact }} | |
path: data | |
- name: zipping files | |
uses: vimtor/action-zip@v1 | |
with: | |
files: data/ | |
recursive: false | |
dest: ${{ steps.generate-name.outputs.artifact }} | |
- name: Staging the artifacts into a folder | |
run: | | |
mkdir data_1 | |
mv *.zip data_1/ | |
cd data_1 | |
git clone -b stats https://github.com/alejandrosantanabonilla/pysoftk.git | |
mv *.zip pysoftk/ | |
- name: Commit files | |
run: | | |
cd data_1/pysoftk | |
git config user.name "$(git log -n 1 --pretty=format:%an)" | |
git config user.email "$(git log -n 1 --pretty=format:%ae)" | |
git add *.zip | |
git commit -m "Add changes" -a | |
git remote set-url origin https://alejandrosantanabonilla:${{ secrets.PYSOFTK_VIEWS }}@github.com/alejandrosantanabonilla/pysoftk.git | |
git push -u origin stats |