-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (47 loc) · 1.55 KB
/
auto-push-main.yml
File metadata and controls
58 lines (47 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Auto Push to Main
on:
push:
branches: [testing]
permissions:
contents: write
pull-requests: write
jobs:
lint-test-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for ahead/behind check
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Lint (ruff)
run: ruff check .
- name: Tests (pytest)
run: pytest tests/ -v
- name: Check if testing is ahead of main
id: ahead_check
run: |
git fetch origin main
AHEAD=$(git rev-list origin/main..HEAD --count)
echo "ahead=$AHEAD" >> "$GITHUB_OUTPUT"
- name: Create PR (testing → main)
if: steps.ahead_check.outputs.ahead != '0'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head testing \
--title "Auto-merge: testing → main (run #${{ github.run_number }})" \
--body "Automatically created by **Auto Push to Main** workflow after lint and tests passed on the \`testing\` branch." \
|| echo "PR already exists — will merge existing PR"
- name: Merge PR into main
if: steps.ahead_check.outputs.ahead != '0'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge testing --merge --delete-branch=false