Skip to content

Commit 5eb3606

Browse files
committed
[ci] Added GitHub Action to replicate to version branch
Created re-usable workflow for replication commits from the master branch to version branch. [change] Created reusable-workflow
1 parent 9e01094 commit 5eb3606

File tree

2 files changed

+55
-40
lines changed

2 files changed

+55
-40
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Replicate Commits to Version Branch
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
module_name:
7+
description: 'The name of the module'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
replicate:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.x'
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
28+
- name: Get version
29+
id: get_version
30+
run: |
31+
VERSION=$(python -c "
32+
from ${{ inputs.module_name }} import VERSION
33+
print(f'{VERSION[0]}.{VERSION[1]}')
34+
")
35+
echo "VERSION=$VERSION" >> $GITHUB_ENV
36+
37+
- name: Configure Git
38+
run: |
39+
git config --global user.name 'github-actions[bot]'
40+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
41+
42+
- name: Rebase changes onto version branch
43+
run: |
44+
if git ls-remote --heads origin $VERSION | grep -sw $VERSION; then
45+
git fetch origin --unshallow
46+
git checkout -b $VERSION origin/$VERSION
47+
git rebase origin/master
48+
else
49+
git checkout -b $VERSION
50+
fi
51+
git push origin $VERSION

.github/workflows/version-branch.yml

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,7 @@ on:
66
- master
77

88
jobs:
9-
replicate:
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v2
15-
16-
- name: Set up Python
17-
uses: actions/setup-python@v2
18-
with:
19-
python-version: '3.x'
20-
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
25-
- name: Get version
26-
id: get_version
27-
run: |
28-
VERSION=$(python -c '
29-
from openwisp_utils import VERSION
30-
print(f"{VERSION[0]}.{VERSION[1]}.x")
31-
')
32-
echo "VERSION=$VERSION" >> $GITHUB_ENV
33-
34-
- name: Configure Git
35-
run: |
36-
git config --global user.name 'github-actions[bot]'
37-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
38-
39-
- name: Rebase changes onto version branch
40-
run: |
41-
if git ls-remote --heads origin $VERSION | grep -sw $VERSION; then
42-
git fetch origin --unshallow
43-
git checkout -b $VERSION origin/$VERSION
44-
git rebase origin/master
45-
else
46-
git checkout -b $VERSION
47-
fi
48-
git push origin $VERSION
9+
version-branch:
10+
uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master
11+
with:
12+
module_name: openwisp_utils

0 commit comments

Comments
 (0)