feat: Initial project setup with CI/CD, Docker, and issue creation script
- Added Codecov configuration to enforce 75% coverage. - Created .dockerignore to exclude unnecessary files from Docker context. - Implemented GitHub Actions CI workflow for linting, testing, and coverage reporting. - Added a workflow to propagate changes between main and development branches. - Configured pre-commit hooks for code quality checks. - Developed a multi-stage Dockerfile for a Python web backend. - Added MIT License to the project. - Created README.md with project overview and setup instructions. - Implemented a script to create GitHub issues from project planning. - Defined development and runtime requirements in requirements.txt and requirements.dev.txt.
This commit is contained in:
96
.github/workflows/propagate-changes.yml
vendored
Normal file
96
.github/workflows/propagate-changes.yml
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
name: Propagate Changes Between Branches
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- development
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
propagate:
|
||||
name: Create PR to synchronize branches
|
||||
runs-on: ubuntu-latest
|
||||
if: "\n github.actor != 'github-actions[bot]' && \
|
||||
github.event.pusher != null\n "
|
||||
steps:
|
||||
- name: Set up Node (for github-script)
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Determine source and target branches
|
||||
id: branches
|
||||
run: |
|
||||
echo "source=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
|
||||
if [ "${GITHUB_REF#refs/heads/}" = "main" ]; then
|
||||
echo "target=development" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "target=main" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create or update Pull Request
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const source = process.env.SOURCE_BRANCH || process.env.GITHUB_REF.replace('refs/heads/','');
|
||||
const target = process.env.TARGET_BRANCH || (source === 'main' ? 'development' : 'main');
|
||||
|
||||
const src = source;
|
||||
const base = target;
|
||||
|
||||
// Do not create PR if source and base are same
|
||||
if (src === base) {
|
||||
core.info(`Source and base are the same (${src}); skipping.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for existing open PRs from src->base
|
||||
const { data: pulls } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: 'open',
|
||||
head: `${context.repo.owner}:${src}`,
|
||||
base: base,
|
||||
});
|
||||
|
||||
if (pulls.length > 0) {
|
||||
core.info(`Found existing PR(s) from ${src} to ${base}. Skipping creation.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Compare commits: only create PR if source is ahead of base
|
||||
const compare = await github.rest.repos.compareCommits({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
base: base,
|
||||
head: src,
|
||||
});
|
||||
|
||||
if (compare.data && compare.data.status === 'identical') {
|
||||
core.info(`${src} and ${base} are identical. No PR needed.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create PR
|
||||
const title = `Propagate changes from ${src} into ${base}`;
|
||||
const body = `Automated PR to propagate commits from ${src} into ${base}.\n\nTriggered by push by @${context.actor}.`;
|
||||
|
||||
const pr = await github.rest.pulls.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title,
|
||||
head: src,
|
||||
base,
|
||||
body,
|
||||
});
|
||||
|
||||
core.info(`Created PR #${pr.data.number}: ${pr.data.html_url}`);
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SOURCE_BRANCH: ${{ steps.branches.outputs.source }}
|
||||
TARGET_BRANCH: ${{ steps.branches.outputs.target }}
|
||||
|
||||
Reference in New Issue
Block a user