|
| 1 | +name: Update and Rebase |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-rebase-branch: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout current branch |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + ref: ${{ github.ref_name }} |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Add upstream remote (if not exists) |
| 19 | + run: | |
| 20 | + if ! git remote | grep -q upstream; then |
| 21 | + git remote add upstream https://github.com/gregkh/linux.git |
| 22 | + fi |
| 23 | +
|
| 24 | + - name: Fetch upstream tags |
| 25 | + run: git fetch upstream --tags |
| 26 | + |
| 27 | + - name: Find latest stable tag for branch |
| 28 | + id: latest_tag |
| 29 | + run: | |
| 30 | + version=$(echo ${{ github.ref_name }} | sed 's/^linux-nvidia-//') |
| 31 | + tag=$(git describe --abbrev=0 --tags upstream/linux-${version}.y) |
| 32 | + echo "tag=$tag" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + - name: Fetch patch branch |
| 35 | + run: git fetch origin ${{ github.ref_name }} |
| 36 | + |
| 37 | + - name: Find merge base between patch branch and updated LTS |
| 38 | + id: merge_base |
| 39 | + run: | |
| 40 | + base=$(git merge-base origin/${{ github.ref_name }} ${{ steps.latest_tag.outputs.tag }}) |
| 41 | + echo "base=$base" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + - name: Create new branch for rebased patches |
| 44 | + run: | |
| 45 | + git checkout -b ${{ github.ref_name }}-${{ steps.latest_tag.outputs.tag }} origin/${{ github.ref_name }} |
| 46 | +
|
| 47 | + - name: Set git user identity |
| 48 | + run: | |
| 49 | + git config --local user.name "github-actions[bot]" |
| 50 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 51 | +
|
| 52 | + - name: Rebase patch branch onto updated LTS |
| 53 | + run: | |
| 54 | + git rebase --onto ${{ steps.latest_tag.outputs.tag }} ${{ steps.merge_base.outputs.base }} |
| 55 | +
|
| 56 | + - name: Push rebased patch branch |
| 57 | + run: | |
| 58 | + git push --force origin HEAD:${{ github.ref_name }}-${{ steps.latest_tag.outputs.tag }} |
0 commit comments