Skip to content

Commit

Permalink
[ci] Added GitHub Action to replicate 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.

[change] Created reusable-workflow
  • Loading branch information
pandafy committed Dec 19, 2024
1 parent 9e01094 commit 5eb3606
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 40 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
44 changes: 4 additions & 40 deletions .github/workflows/version-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,7 @@ on:
- master

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 openwisp_utils import VERSION
print(f"{VERSION[0]}.{VERSION[1]}.x")
')
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
version-branch:
uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master
with:
module_name: openwisp_utils

0 comments on commit 5eb3606

Please sign in to comment.