Skip to content

Commit be703aa

Browse files
authored
fix: updated call timing
fix: updated call timing
2 parents 7020056 + 6574e36 commit be703aa

5 files changed

Lines changed: 121 additions & 35 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Auto-merge reusable workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
head_branch:
7+
description: 'Branch name to find PR for'
8+
required: false
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
auto-merge:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Auto-merge matching PR
20+
uses: actions/github-script@v7
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
script: |
24+
// Use the provided input; caller should supply `head_branch` when invoking.
25+
const head_branch = "${{ inputs.head_branch }}";
26+
const owner = context.repo.owner;
27+
const repo = context.repo.repo;
28+
29+
if (!head_branch) {
30+
core.info('No head_branch provided; nothing to do.');
31+
return;
32+
}
33+
34+
core.info(`Auto-merge triggered for branch: ${head_branch}`);
35+
36+
const prs = await github.rest.pulls.list({
37+
owner,
38+
repo,
39+
head: `${owner}:${head_branch}`,
40+
state: 'open',
41+
});
42+
43+
if (!prs.data || prs.data.length === 0) {
44+
core.info(`No open pull request found for branch ${head_branch}`);
45+
return;
46+
}
47+
48+
const pr = prs.data[0];
49+
50+
if (pr.draft) {
51+
core.info(`Pull request #${pr.number} is a draft; skipping merge.`);
52+
return;
53+
}
54+
55+
try {
56+
const res = await github.rest.pulls.merge({
57+
owner,
58+
repo,
59+
pull_number: pr.number,
60+
merge_method: 'merge',
61+
commit_title: head_branch,
62+
commit_message: '',
63+
});
64+
65+
if (res.data.merged) {
66+
core.info(`Successfully merged PR #${pr.number} (branch ${head_branch}).`);
67+
} else {
68+
core.info(`Merge attempt returned: ${JSON.stringify(res.data)}`);
69+
}
70+
} catch (err) {
71+
core.setFailed(`Failed to merge PR #${pr.number}: ${err}`);
72+
}
73+
74+
- name: Done
75+
run: echo "auto-merge finished"

.github/workflows/ci-cd.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
needs: [lint, cache]
2424
uses: milsman2/python-app-template/.github/workflows/pytest.yaml@main
2525

26-
docker:
26+
docker-build-and-image-scan:
2727
if: github.event_name == 'push'
2828
needs: test
2929
uses: milsman2/python-app-template/.github/workflows/docker-build-and-scan.yaml@main
@@ -37,8 +37,19 @@ jobs:
3737

3838
release:
3939
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
40-
needs: [test, docker]
40+
needs: [test, docker-build-and-image-scan]
4141
uses: ./.github/workflows/release.yaml
4242
permissions:
4343
contents: write
4444
secrets: inherit
45+
46+
trigger-auto-merge:
47+
needs: release
48+
if: needs.release.result == 'success'
49+
uses: ./.github/workflows/auto-merge-on-release.yml
50+
permissions:
51+
contents: write
52+
pull-requests: write
53+
with:
54+
head_branch: ${{ github.ref_name }}
55+
secrets: inherit

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ dependencies = [
2020
"pylint-pydantic>=0.4.1",
2121
"pytest>=9.0.2",
2222
"rich>=14.3.2",
23-
"ruff>=0.15.1",
23+
"ruff>=0.15.2",
2424
]
2525

2626
[project.optional-dependencies]
27-
build = ["uv >= 0.10.4"]
27+
build = ["uv >= 0.10.6"]
2828

2929
[build-system]
30-
requires = ["uv_build >= 0.10.4"]
30+
requires = ["uv_build >= 0.10.6"]
3131
build-backend = "uv_build"
3232

3333
[project.scripts]

src/sample_python_app/app/scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def shutdown(signum, frame):
3737
scheduler.add_job(
3838
fetcher.fetch,
3939
trigger="interval",
40-
hours=24,
40+
minutes=5,
4141
next_run_time=datetime.now(UTC),
4242
misfire_grace_time=3600,
4343
coalesce=True,

uv.lock

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)