Update and Rebase #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update and Rebase | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Branch to rebase (leave empty for all)' | |
| required: false | |
| type: choice | |
| options: | |
| - '' | |
| - linux-nvidia-6.6 | |
| - linux-nvidia-6.12 | |
| - linux-nvidia-6.18 | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: Build matrix | |
| id: set-matrix | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.branch }}" ]; then | |
| branches='${{ inputs.branch }}' | |
| else | |
| branches='linux-nvidia-6.6 linux-nvidia-6.12 linux-nvidia-6.18' | |
| fi | |
| matrix='{"include":[' | |
| first=true | |
| for branch in $branches; do | |
| version=$(echo "$branch" | sed 's/^linux-nvidia-//') | |
| # Query tags remotely without fetching | |
| tag=$(git ls-remote --tags https://github.com/gregkh/linux.git "v${version}.*" | \ | |
| grep -v '\^{}' | \ | |
| sed 's|.*/||' | \ | |
| sort -V | \ | |
| tail -1) | |
| if [ "$first" = true ]; then | |
| first=false | |
| else | |
| matrix+=',' | |
| fi | |
| matrix+="{\"branch\":\"$branch\",\"tag\":\"$tag\"}" | |
| done | |
| matrix+=']}' | |
| echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
| update-rebase-branch: | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} | |
| outputs: | |
| branch-6-6: ${{ steps.mark-success.outputs.branch-6-6 }} | |
| branch-6-12: ${{ steps.mark-success.outputs.branch-6-12 }} | |
| branch-6-18: ${{ steps.mark-success.outputs.branch-6-18 }} | |
| steps: | |
| - name: Checkout target branch | |
| run: | | |
| git init -q | |
| git remote add origin https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git | |
| git fetch origin ${{ matrix.branch }} | |
| git checkout -b ${{ matrix.branch }} origin/${{ matrix.branch }} | |
| - name: Fetch upstream tag | |
| run: | | |
| git remote add upstream https://github.com/gregkh/linux.git | |
| git fetch upstream tag ${{ matrix.tag }} --no-tags | |
| - name: Find merge base | |
| id: merge_base | |
| run: | | |
| base=$(git merge-base HEAD ${{ matrix.tag }}) | |
| echo "base=$base" >> $GITHUB_OUTPUT | |
| - name: Create rebased branch | |
| run: | | |
| git checkout -b ${{ matrix.branch }}-${{ matrix.tag }} | |
| - name: Set git user identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Rebase onto upstream tag | |
| run: | | |
| git rebase --onto ${{ matrix.tag }} ${{ steps.merge_base.outputs.base }} | |
| - name: Push rebased branch | |
| run: | | |
| git push --force origin HEAD:${{ matrix.branch }}-${{ matrix.tag }} | |
| - name: Mark rebase successful | |
| id: mark-success | |
| run: | | |
| key=$(echo "${{ matrix.branch }}" | sed 's/linux-nvidia-/branch-/' | tr '.' '-') | |
| echo "${key}=${{ matrix.branch }}-${{ matrix.tag }}" >> $GITHUB_OUTPUT | |
| build-6-6: | |
| needs: [prepare, update-rebase-branch] | |
| if: ${{ !cancelled() && needs.update-rebase-branch.outputs.branch-6-6 != '' }} | |
| uses: ./.github/workflows/kernel-build.yml | |
| with: | |
| branch: ${{ needs.update-rebase-branch.outputs.branch-6-6 }} | |
| build-6-12: | |
| needs: [prepare, update-rebase-branch] | |
| if: ${{ !cancelled() && needs.update-rebase-branch.outputs.branch-6-12 != '' }} | |
| uses: ./.github/workflows/kernel-build.yml | |
| with: | |
| branch: ${{ needs.update-rebase-branch.outputs.branch-6-12 }} | |
| build-6-18: | |
| needs: [prepare, update-rebase-branch] | |
| if: ${{ !cancelled() && needs.update-rebase-branch.outputs.branch-6-18 != '' }} | |
| uses: ./.github/workflows/kernel-build.yml | |
| with: | |
| branch: ${{ needs.update-rebase-branch.outputs.branch-6-18 }} |