From c1562747b9d3906b271e323d9b043509918211cd Mon Sep 17 00:00:00 2001 From: Ayman Naji Date: Tue, 9 Jan 2024 10:32:42 -0800 Subject: [PATCH 1/2] added traffic branch, testing new traffic action and cron job Signed-off-by: Ayman Naji --- .github/workflows/traffic_workflow.yml | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/traffic_workflow.yml diff --git a/.github/workflows/traffic_workflow.yml b/.github/workflows/traffic_workflow.yml new file mode 100644 index 00000000..7ce5c262 --- /dev/null +++ b/.github/workflows/traffic_workflow.yml @@ -0,0 +1,32 @@ +on: + workflow_dispatch: + 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 + - uses: actions/checkout@v2 + with: + ref: "traffic" + + # Calculates traffic and clones and stores in CSV file + - name: Repository traffic + uses: sangonzal/repository-traffic-action@v.0.1.6 + env: + TRAFFIC_ACTION_TOKEN: ${{ secrets.TRAFFIC_ACTION_TOKEN }} + + # Commits files to repository + - name: Commit changes + uses: EndBug/add-and-commit@v4 + with: + author_name: Ayman Naji + add: "./traffic/*" + ref: "traffic" # commits to branch "traffic" \ No newline at end of file From c5b0570b933da77e544ffa1b8f56e77813c059b5 Mon Sep 17 00:00:00 2001 From: Ayman Naji Date: Tue, 9 Jan 2024 12:17:41 -0800 Subject: [PATCH 2/2] added test script for getting traffic data Signed-off-by: Ayman Naji --- .github/workflows/traffic_workflow.yml | 58 +++++++++++++++++++------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/.github/workflows/traffic_workflow.yml b/.github/workflows/traffic_workflow.yml index 7ce5c262..e314fd77 100644 --- a/.github/workflows/traffic_workflow.yml +++ b/.github/workflows/traffic_workflow.yml @@ -1,5 +1,7 @@ +name: run github-traffic-stats + on: - workflow_dispatch: + workflow_dispatch: # Allow for running this manually. schedule: # runs daily at midnight (UTC) - cron: '0 0 * * *' @@ -13,20 +15,48 @@ jobs: # 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 - - uses: actions/checkout@v2 + - name: checkout repo content + uses: actions/checkout@v2 with: ref: "traffic" - - # Calculates traffic and clones and stores in CSV file - - name: Repository traffic - uses: sangonzal/repository-traffic-action@v.0.1.6 + + - 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 }} - - # Commits files to repository - - name: Commit changes - uses: EndBug/add-and-commit@v4 + 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 "action@github.com" + 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/github-push-action@v0.6.0 with: - author_name: Ayman Naji - add: "./traffic/*" - ref: "traffic" # commits to branch "traffic" \ No newline at end of file + github_token: ${{ secrets.TRAFFIC_ACTION_TOKEN }} + branch: traffic \ No newline at end of file