Skip to content

Commit 09d5aa2

Browse files
lets see
1 parent d4addbb commit 09d5aa2

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

.github/workflows/actions.yml

+12-10
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,41 @@ name: Run Python script and log output
22

33
on:
44
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.
66
push:
77
branches:
8-
- main
8+
- main
99

1010
jobs:
1111
run_script:
1212
runs-on: ubuntu-latest
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v2
1717

1818
- name: Setup Python
1919
uses: actions/setup-python@v4
2020
with:
21-
python-version: '3.9'
21+
python-version: "3.9"
2222

2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install -r requirements.txt # Instalira pakete iz requirements.txt
26+
pip install -r requirements.txt
2727
2828
- name: Run Python script
29+
env:
30+
MY_SECRET: ${{ secrets.MY_GITHUB_TOKEN }}
2931
run: |
30-
python main.py # Pokreće Python skriptu i upisuje izlaz u open-source.txt
31-
32+
python main.py
33+
3234
- name: Commit and push changes
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
3337
run: |
3438
git config --local user.email "action@github.com"
3539
git config --local user.name "GitHub Action"
3640
git add open-source.txt
3741
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

main.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.")

main/main.py

-11
This file was deleted.

0 commit comments

Comments
 (0)