File tree 3 files changed +30
-21
lines changed
3 files changed +30
-21
lines changed Original file line number Diff line number Diff line change @@ -2,39 +2,41 @@ name: Run Python script and log output
2
2
3
3
on :
4
4
schedule :
5
- - cron : ' 0 9 01 * *' # At 09:00 on day-of-month 1.
5
+ - cron : " 0 9 01 * *" # At 09:00 on day-of-month 1.
6
6
push :
7
7
branches :
8
- - main
8
+ - main
9
9
10
10
jobs :
11
11
run_script :
12
12
runs-on : ubuntu-latest
13
13
14
14
steps :
15
15
- name : Checkout repository
16
- uses : actions/checkout@v2
16
+ uses : actions/checkout@v2
17
17
18
18
- name : Setup Python
19
19
uses : actions/setup-python@v4
20
20
with :
21
- python-version : ' 3.9'
21
+ python-version : " 3.9"
22
22
23
23
- name : Install dependencies
24
24
run : |
25
25
python -m pip install --upgrade pip
26
- pip install -r requirements.txt # Instalira pakete iz requirements.txt
26
+ pip install -r requirements.txt
27
27
28
28
- name : Run Python script
29
+ env :
30
+ MY_SECRET : ${{ secrets.MY_GITHUB_TOKEN }}
29
31
run : |
30
- python main.py # Pokreće Python skriptu i upisuje izlaz u open-source.txt
31
-
32
+ python main.py
33
+
32
34
- name : Commit and push changes
35
+ env :
36
+ GITHUB_TOKEN : ${{ secrets.MY_GITHUB_TOKEN }}
33
37
run : |
34
38
git config --local user.email "action@github.com"
35
39
git config --local user.name "GitHub Action"
36
40
git add open-source.txt
37
41
git diff-index --quiet HEAD || (git commit -a -m "Update open-source.txt log" --allow-empty)
38
- git push origin main
39
- env :
40
- GITHUB_TOKEN : ${{ secrets.MY_GITHUB_TOKEN }}
42
+ git push origin main
Original file line number Diff line number Diff line change
1
+ import requests
2
+ import logging
3
+
4
+ logging .basicConfig (filename = 'open-source.txt' ,
5
+ level = logging .INFO , format = '%(asctime)s - %(message)s' )
6
+
7
+ response = requests .get (
8
+ "https://api.github.com/search/repositories?q=language:python+stars:%3E1&sort=stars&order=desc" )
9
+ response .raise_for_status ()
10
+
11
+ data = response .json ()["items" ]
12
+
13
+ logging .info ("GitHub Repositories with Python language:" )
14
+
15
+ for repo in data :
16
+ owner_url = repo ["owner" ]["html_url" ]
17
+ logging .info (f"Open-source Projects repository URL: { owner_url } " )
18
+ logging .info ("Logging completed." )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments