Skip to content

Commit

Permalink
[ci] Added GitHub workflow to replicate commits to version branch
Browse files Browse the repository at this point in the history
Created re-usable workflow for replication commits from the
master branch to version branch.
  • Loading branch information
pandafy committed Dec 19, 2024
1 parent e0113ba commit 3b51f3d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/reusable-version-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Replicate Commits to Version Branch

on:
workflow_call:
inputs:
module_name:
description: 'The name of the module'
required: true
type: string

jobs:
replicate:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Get version
id: get_version
run: |
VERSION=$(python -c "
from ${{ inputs.module_name }} import VERSION
print(f'{VERSION[0]}.{VERSION[1]}')
")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Rebase changes onto version branch
run: |
if git ls-remote --heads origin $VERSION | grep -sw $VERSION; then
git fetch origin --unshallow
git checkout -b $VERSION origin/$VERSION
git rebase origin/master
else
git checkout -b $VERSION
fi
git push origin $VERSION
12 changes: 12 additions & 0 deletions .github/workflows/version-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Replicate Commits to Version Branch

on:
push:
branches:
- master

jobs:
version-branch:
uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master
with:
module_name: openwisp_utils

0 comments on commit 3b51f3d

Please sign in to comment.