Skip to content

Commit 7444bcf

Browse files
authored
Update main.yaml
1 parent 8ff3f5f commit 7444bcf

1 file changed

Lines changed: 11 additions & 53 deletions

File tree

.github/workflows/main.yaml

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,17 @@
1-
name: Python Code Bot (Ruff)
1+
name: CI Example
22

3-
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
3+
on: [push]
84

9-
jobs:
10-
lint-and-fix:
11-
runs-on: ubuntu-latest
12-
# Даем боту права на запись, чтобы он мог пушить исправления
13-
permissions:
14-
contents: write
15-
16-
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
with:
20-
ref: ${{ github.head_ref }}
21-
22-
- name: Set up Python
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: '3.11'
5+
# Ограничение прав GITHUB_TOKEN на уровне всего workflow
6+
permissions:
7+
contents: read # Разрешаем только чтение кода (необходимо для checkout)
268

27-
- name: Install Ruff
28-
run: pip install ruff
29-
30-
- name: Fix violations and Format code
31-
# Ruff исправляет импорты, удаляет неиспользуемый код и форматирует стиль (как Black)
32-
run: |
33-
ruff check --fix .
34-
ruff format .
35-
36-
- name: Commit changes
37-
# Бот автоматически коммитит правки, если они были
38-
uses: stefanzweifel/git-auto-commit-action@v5
39-
with:
40-
commit_message: "style: авто-форматирование кода (Ruff)"
41-
branch: ${{ github.head_ref }}
42-
43-
tests:
9+
jobs:
10+
build:
4411
runs-on: ubuntu-latest
45-
needs: lint-and-fix # Запускаем тесты только после того, как бот причесал код
4612
steps:
47-
- name: Checkout code
13+
- name: ⤵️ Check out repository code
4814
uses: actions/checkout@v4
49-
- name: Set up Python
50-
uses: actions/setup-python@v5
51-
with:
52-
python-version: '3.11'
53-
- name: Install dependencies
54-
run: |
55-
pip install pytest
56-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
57-
- name: Run Tests
58-
run: pytest
59-
15+
16+
- name: 🚀 Run a script
17+
run: echo "Hello, GitHub Actions 2026! Permissions are secured."

0 commit comments

Comments
 (0)