Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/auto-merge-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Auto-merge reusable workflow

on:
workflow_call:
inputs:
head_branch:
description: 'Branch name to find PR for'
required: false
type: string

permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: Auto-merge matching PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Use the provided input; caller should supply `head_branch` when invoking.
const head_branch = "${{ inputs.head_branch }}";
const owner = context.repo.owner;
const repo = context.repo.repo;

if (!head_branch) {
core.info('No head_branch provided; nothing to do.');
return;
}

core.info(`Auto-merge triggered for branch: ${head_branch}`);

const prs = await github.rest.pulls.list({
owner,
repo,
head: `${owner}:${head_branch}`,
state: 'open',
});

if (!prs.data || prs.data.length === 0) {
core.info(`No open pull request found for branch ${head_branch}`);
return;
}

const pr = prs.data[0];

if (pr.draft) {
core.info(`Pull request #${pr.number} is a draft; skipping merge.`);
return;
}

try {
const res = await github.rest.pulls.merge({
owner,
repo,
pull_number: pr.number,
merge_method: 'merge',
commit_title: head_branch,
commit_message: '',
});

if (res.data.merged) {
core.info(`Successfully merged PR #${pr.number} (branch ${head_branch}).`);
} else {
core.info(`Merge attempt returned: ${JSON.stringify(res.data)}`);
}
} catch (err) {
core.setFailed(`Failed to merge PR #${pr.number}: ${err}`);
}

- name: Done
run: echo "auto-merge finished"
15 changes: 13 additions & 2 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
needs: [lint, cache]
uses: milsman2/python-app-template/.github/workflows/pytest.yaml@main

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

release:
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
needs: [test, docker]
needs: [test, docker-build-and-image-scan]
uses: ./.github/workflows/release.yaml
permissions:
contents: write
secrets: inherit

trigger-auto-merge:
needs: release
if: needs.release.result == 'success'
uses: ./.github/workflows/auto-merge-on-release.yml
permissions:
contents: write
pull-requests: write
with:
head_branch: ${{ github.ref_name }}
secrets: inherit
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ dependencies = [
"pylint-pydantic>=0.4.1",
"pytest>=9.0.2",
"rich>=14.3.2",
"ruff>=0.15.1",
"ruff>=0.15.2",
]

[project.optional-dependencies]
build = ["uv >= 0.10.4"]
build = ["uv >= 0.10.6"]

[build-system]
requires = ["uv_build >= 0.10.4"]
requires = ["uv_build >= 0.10.6"]
build-backend = "uv_build"

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion src/sample_python_app/app/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def shutdown(signum, frame):
scheduler.add_job(
fetcher.fetch,
trigger="interval",
hours=24,
minutes=5,
next_run_time=datetime.now(UTC),
misfire_grace_time=3600,
coalesce=True,
Expand Down
58 changes: 29 additions & 29 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading