-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from IBM/traffic
Test: Github Traffic cron script
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: run github-traffic-stats | ||
|
||
on: | ||
workflow_dispatch: # Allow for running this manually. | ||
schedule: | ||
# runs daily at midnight (UTC) | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
# This workflow contains a single job called "traffic" | ||
traffic: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- name: checkout repo content | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: "traffic" | ||
|
||
- name: setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' # install the python version needed | ||
|
||
- name: install python packages | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install github_traffic_stats | ||
pip install certifi==2017.7.27.1 | ||
pip install chardet==3.0.4 | ||
pip install idna==2.6 | ||
pip install pkginfo==1.4.2 | ||
pip install psycopg2-binary==2.7.4 | ||
pip install requests==2.21.0 | ||
pip install requests-toolbelt==0.8.0 | ||
pip install tqdm==4.19.2 | ||
pip install twine==1.11.0 | ||
pip install urllib3>=1.24.2 | ||
- name: execute py script # run main.py | ||
env: | ||
TRAFFIC_ACTION_TOKEN: ${{ secrets.TRAFFIC_ACTION_TOKEN }} | ||
run: | | ||
mkdir $(date +%Y-%m-%d)-traffic-stats | ||
cd $(date +%Y-%m-%d)-traffic-stats | ||
gts Ay1man2:${{ secrets.TRAFFIC_ACTION_TOKEN }} CRAIG save_csv -o IBM | ||
- name: commit files | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add -A | ||
git diff-index --quiet HEAD || (git commit -a -m "daily traffic data uploaded" --allow-empty) | ||
- name: push changes | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.TRAFFIC_ACTION_TOKEN }} | ||
branch: traffic |