Skip to content

Commit 05719c9

Browse files
committed
.github: workflows: add workflows for automatic rebase
Regarding the "rebase.yml". We cannot simply rebase commits from TrenchBoot/grub on top of the commits in the QubesOS/qubes-grub2, because: 1. The actual history for the grub component is held in patches in the QubesOS/qubes-grub2 repository, so we need to do a conversion from patches to commits every time we want to try to rebase. 2. We want to track the changes to the other files from the QubesOS/qubes-grub2, except for the patches for the grub component, as versions of these files might be closely related to the changes in the patches for the grub component. Other changes that should be made due to the history format difference between the QubesOS/qubes-grub2 and TrenchBoot/grub should will be resolved by the follwoing commit when the actual rebase happens: 2f477ee Signed-off-by: Danil Klimuk <daniil.klimuk@3mdeb.com>
1 parent 7259d55 commit 05719c9

1 file changed

Lines changed: 145 additions & 0 deletions

File tree

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Build the last successful automatic rebase of tb-dev branch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dry_run:
7+
description: >
8+
Set this input to some value to do a dry run without
9+
building the packages to test the rebase.
10+
required: false
11+
type: string
12+
schedule:
13+
- cron: '0 0 * * 6'
14+
15+
concurency:
16+
group: automatic-rebase
17+
18+
jobs:
19+
prep-rebase:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
steps:
24+
- name: Checkout qubes-grub2
25+
uses: actions/checkout@v6
26+
with:
27+
repository: QubesOS/qubes-grub2
28+
path: qubes-grub2
29+
- name: Checkout downstream grub repository
30+
uses: actions/checkout@v6
31+
with:
32+
repository: TrenchBoot/grub
33+
token: ${{ secrets.TRENCHBOOT_REBASE_TOKEN }}
34+
path: grub
35+
- name: Read upstream version from qubes-grub2
36+
id: version
37+
run: echo "version=$(tr -d '[:space:]' < qubes-grub2/version)" >> "$GITHUB_OUTPUT"
38+
- name: Add upstream remote and fetch version tag
39+
working-directory: grub
40+
env:
41+
UPSTREAM_TAG: grub-${{ steps.version.outputs.version }}
42+
run: |
43+
git remote add upstream https://git.savannah.gnu.org/git/grub.git
44+
git fetch upstream "refs/tags/${UPSTREAM_TAG}:refs/tags/${UPSTREAM_TAG}"
45+
- name: Apply qubes-grub2 patches on top of upstream tag
46+
working-directory: grub
47+
env:
48+
UPSTREAM_TAG: grub-${{ steps.version.outputs.version }}
49+
run: |
50+
git config user.name 'github-actions[bot]'
51+
git config user.email 'github-actions[bot]@users.noreply.github.com'
52+
git checkout -b qubes-grub2-with-patches-rebase-prep "$UPSTREAM_TAG"
53+
SPEC="../qubes-grub2/grub2.spec.in"
54+
mapfile -t PATCHES < <(grep -E '^Patch[0-9]+:' "$SPEC" | awk '{print $2}')
55+
for patch_file in "${PATCHES[@]}"; do
56+
sed -n -i '/^From:/,$p' "$patch_file"
57+
git am --committer-date-is-author-date --no-gpg-sign "../qubes-grub2/${patch_file}"
58+
escaped=$(printf '%s' "$patch_file" | sed 's/\./\\./g')
59+
sed -i "/^Patch[0-9]*:[[:space:]]*${escaped}[[:space:]]*$/d" "$SPEC"
60+
rm -f "../qubes-grub2/${patch_file}"
61+
done
62+
- name: Copy QubesOS RPM files to downstream repository
63+
run: |
64+
cp -r qubes-grub2/* grub/
65+
cd grub
66+
git add -A
67+
git commit -m "QubesOS RPM files and Qubes builder metadata"
68+
- name: Push qubes-grub2-with-patches branch to downstream
69+
working-directory: grub
70+
run: |
71+
git push origin qubes-grub2-with-patches-rebase-prep || \
72+
echo "Cannot prepare for automatic rebase!" >&2
73+
try-rebase:
74+
needs: prep-rebase
75+
uses: TrenchBoot/.github/.github/workflows/rebase.yml@master
76+
secrets:
77+
first-remote-token: ${{secrets.TRENCHBOOT_REBASE_TOKEN}}
78+
permissions:
79+
# For creation/deletion/pushing to branches and creating PRs
80+
contents: write
81+
with:
82+
downstream-repo: 'https://github.com/TrenchBoot/grub.git'
83+
downstream-branch: 'tb-dev'
84+
upstream-repo: 'https://github.com/TrenchBoot/grub.git'
85+
upstream-branch: 'qubes-grub2-with-patches-rebase-prep'
86+
commit-user-name: 'github-actions[bot]'
87+
commit-user-email: 'github-actions[bot]@users.noreply.github.com'
88+
cicd-trigger-resume: '7. Rerun the workflow https://github.com/TrenchBoot/grub/actions/runs/${{ github.run_id }} to resume automated rebase.'
89+
cleanup-after-rebase-attemp:
90+
needs: try-rebase
91+
if: always()
92+
runs-on: ubuntu-latest
93+
permissions:
94+
contents: read
95+
steps:
96+
- name: Checkout downstream grub repository
97+
uses: actions/checkout@v6
98+
with:
99+
repository: TrenchBoot/grub
100+
token: ${{ secrets.TRENCHBOOT_REBASE_TOKEN }}
101+
path: grub
102+
- name: Delete qubes-grub2-with-patches branch from downstream
103+
working-directory: grub
104+
env:
105+
TOKEN: ${{ secrets.TRENCHBOOT_REBASE_TOKEN }}
106+
run: |
107+
git push "https://${TOKEN}@github.com/TrenchBoot/grub.git" \
108+
--delete qubes-grub2-with-patches-rebase-prep
109+
get-version:
110+
runs-on: ubuntu-latest
111+
needs: try-rebase
112+
if: inputs.dry_run == ''
113+
outputs:
114+
version: ${{ steps.read-version.outputs.version }}
115+
steps:
116+
- uses: actions/checkout@v6
117+
with:
118+
ref: 'aem-next-rebased'
119+
- name: Read version of the QubesOS Component from version file
120+
id: read-version
121+
run: echo "version=$(cat version)" >> "$GITHUB_OUTPUT"
122+
qubes-dom0-package:
123+
needs: get-version
124+
uses: TrenchBoot/.github/.github/workflows/qubes-dom0-packagev2.yml@master
125+
with:
126+
qubes-component: 'grub2'
127+
qubes-component-branch: 'tb-dev-rebased'
128+
qubes-pkg-src-dir: '.'
129+
qubes-pkg-version: ${{ needs.get-version.outputs.version }}
130+
trigger-gitea-cicd:
131+
needs: qubes-dom0-package
132+
uses: TrenchBoot/.github/.github/workflows/trigger-woodpecker-pipeline.yml@master
133+
secrets:
134+
woodpecker-token: ${{ secrets.WOODPECKER_TOKEN }}
135+
with:
136+
api-url: 'https://ci.3mdeb.com'
137+
owner: 'zarhus'
138+
repo: 'trenchboot-release-cicd-pipeline'
139+
ref: 'master'
140+
inputs: >-
141+
--input GITHUB_REPO=grub
142+
--input GITHUB_SHA=${{ github.sha }}
143+
--input GITHUB_RUN_ID=${{ github.run_id }}
144+
--input QUBES_COMPONENT=grub2
145+
--input WORKFLOW=sign-and-publish-test-rpms

0 commit comments

Comments
 (0)