Skip to content

Commit f6ebc49

Browse files
2 parents f3a17e4 + 768d596 commit f6ebc49

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
name: Fetch Traffic Data for Pub_TRR_RAmodified_PitC
3+
4+
on:
5+
schedule:
6+
- cron: "0 0 * * 1" # Runs weekly at midnight UTC every Monday
7+
workflow_dispatch: # Allows manual triggering
8+
9+
jobs:
10+
collect-traffic:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Check Out the Current Repository
15+
- name: Checkout Current Repository
16+
uses: actions/checkout@v3
17+
18+
# Step 2: Fetch Repository Traffic Data
19+
- name: Fetch Traffic Data
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.TRAFFIC_DATA_TOKEN }}
22+
run: |
23+
# Fetch views data
24+
curl -H "Authorization: token $GITHUB_TOKEN" \
25+
https://api.github.com/repos/TFHRC-ABML/Pub_TRR_RAmodified_PitC/traffic/views \
26+
-o views.json
27+
28+
# Fetch clones data
29+
curl -H "Authorization: token $GITHUB_TOKEN" \
30+
https://api.github.com/repos/TFHRC-ABML/Pub_TRR_RAmodified_PitC/traffic/clones \
31+
-o clones.json
32+
33+
# Save data with timestamped filenames
34+
mkdir -p traffic-data
35+
mv views.json traffic-data/views-$(date +%F).json
36+
mv clones.json traffic-data/clones-$(date +%F).json
37+
38+
# Step 3: Push Data to the Private Repository
39+
- name: Push Data to Another Repository
40+
env:
41+
TRAFFIC_DATA_TOKEN: ${{ secrets.TRAFFIC_DATA_TOKEN }}
42+
run: |
43+
# Clone the target private repository
44+
git clone https://x-access-token:${TRAFFIC_DATA_TOKEN}@github.com/TFHRC-ABML/Traffic_Data_Archive.git
45+
46+
# Copy the new traffic data into the target repository
47+
cp -r traffic-data/* Traffic_Data_Archive/Pub_TRR_RAmodified_PitC/
48+
49+
# Commit and push changes
50+
cd Traffic_Data_Archive
51+
git config user.name "github-actions"
52+
git config user.email "github-actions@github.com"
53+
git add .
54+
git commit -m "Update traffic data for $(date +%F)" || echo "No changes to commit"
55+
git push

0 commit comments

Comments
 (0)