-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
53 lines (44 loc) · 1.62 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Alembic Rebase
description: Maintain a linear history of Alembic migrations without having to manually resolve merge conflict.
author: Chan Kang <[email protected]>
inputs:
main-branch-name:
required: false
default: main
dry-run:
required: false
default: false
description: "If set to true, the action will not commit the changes to the repository."
working-directory:
required: false
default: ./
runs:
using: "composite"
steps:
- uses: astral-sh/setup-uv@v3
- name: Get the head revision of main branch
id: head_on_main
run: |
cd ${{ inputs.working-directory }} &&
git fetch origin ${{ inputs.main-branch-name }} &&
git checkout origin/${{ inputs.main-branch-name }} &&
(echo -n "revision=" && uv run python ${{ github.action_path }}/alembic_rebase/head_revision.py) >> $GITHUB_OUTPUT
shell: bash
- name: Rebase the feature branch's revision to main branch's head.
run: |
cd ${{ inputs.working-directory }} &&
git checkout - &&
uv run python ${{ github.action_path }}/alembic_rebase/rebase.py --new-parent ${{ steps.head_on_main.outputs.revision }}
shell: bash
- run: git diff
shell: bash
- name: Display the modified history.
run: cd ${{ inputs.working-directory }} && uv run alembic history
shell: bash
- uses: stefanzweifel/git-auto-commit-action@v5
if: ${{ ! inputs.dry-run }}
with:
commit_message: rebasing the migration with the new parent revision "${{ steps.head_on_main.outputs.revision }}"
branding:
icon: 'git-commit'
color: orange