Skip to content

Commit dd28bd6

Browse files
committed
extend workflow to support matrix
Signed-off-by: flouthoc <[email protected]>
1 parent 3f1e910 commit dd28bd6

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

.github/workflows/opendownstream-pr.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ on:
1313
jobs:
1414
sync:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
include:
19+
- repo_name: buildah
20+
fork_repo: flouthoc/buildah
21+
upstream_repo: github.com/containers/buildah
22+
- repo_name: podman
23+
fork_repo: flouthoc/podman
24+
upstream_repo: github.com/containers/podman
1625
steps:
1726
- name: 'Checkout Self'
1827
uses: actions/checkout@v5
@@ -23,24 +32,24 @@ jobs:
2332
with:
2433
go-version: 'stable'
2534

26-
- name: 'Checkout forked buildah'
35+
- name: 'Checkout forked ${{ matrix.repo_name }}'
2736
uses: actions/checkout@v5
2837
with:
29-
repository: 'flouthoc/buildah' # The target repository
30-
path: 'buildah' # Checkout into a sub-directory
38+
repository: '${{ matrix.fork_repo }}' # The target repository
39+
path: '${{ matrix.repo_name }}' # Checkout into a sub-directory
3140
token: ${{ secrets.VENDOR_TOKEN_PODMANBOT }}
3241

33-
- name: 'Vendor Code from this repo to buildah'
42+
- name: 'Vendor Code from this repo to ${{ matrix.repo_name }}'
3443
run: |
3544
# Get the current commit SHA from the PR
3645
COMMIT_SHA="${{ github.event.pull_request.head.sha }}"
3746
echo "Using commit SHA: $COMMIT_SHA"
3847
39-
cd buildah
48+
cd ${{ matrix.repo_name }}
4049
# Create a unique branch name based on the container-libs PR number
4150
BRANCH_NAME="sync/container-libs-${{ github.event.pull_request.number }}"
4251
git switch -c $BRANCH_NAME
43-
git remote add upstream https://github.com/containers/buildah.git
52+
git remote add upstream https://${{ matrix.upstream_repo }}.git
4453
git fetch upstream
4554
git rebase upstream/main
4655
@@ -66,9 +75,9 @@ jobs:
6675
echo "Updated go.mod:"
6776
cat go.mod
6877
69-
- name: 'Commit and Push to buildah'
78+
- name: 'Commit and Push to ${{ matrix.repo_name }}'
7079
run: |
71-
cd buildah
80+
cd ${{ matrix.repo_name }}
7281
git config user.name "github-actions[bot]"
7382
git config user.email "github-actions[bot]@users.noreply.github.com"
7483
@@ -83,15 +92,15 @@ jobs:
8392
8493
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
8594
86-
- name: 'Create or Update Pull Request in Buildah'
95+
- name: 'Create or Update Pull Request in ${{ matrix.repo_name }}'
8796
id: create_pr
8897
env:
8998
GH_TOKEN: ${{ secrets.VENDOR_TOKEN_PODMANBOT }}
9099
SELF_REPO_PR_NUMBER: ${{ github.event.pull_request.number }}
91100
SELF_REPO_PR_URL: ${{ github.event.pull_request.html_url }}
92101
SELF_REPO_PR_TITLE: ${{ github.event.pull_request.title }}
93102
run: |
94-
cd buildah
103+
cd ${{ matrix.repo_name }}
95104
96105
BRANCH_NAME="sync/container-libs-${{ github.event.pull_request.number }}"
97106
PR_TITLE="Sync: ${SELF_REPO_PR_TITLE}"
@@ -100,7 +109,7 @@ jobs:
100109
# Check if PR already exists for this branch
101110
echo "Searching for existing PR with branch: $BRANCH_NAME"
102111
103-
EXISTING_PR_URL=$(gh pr list --repo flouthoc/buildah --head "$BRANCH_NAME" --json url --jq '.[0].url // empty' 2>/dev/null || echo "")
112+
EXISTING_PR_URL=$(gh pr list --repo ${{ matrix.fork_repo }} --head "$BRANCH_NAME" --json url --jq '.[0].url // empty' 2>/dev/null || echo "")
104113
105114
if [ -n "$EXISTING_PR_URL" ]; then
106115
echo "Found existing PR: $EXISTING_PR_URL"
@@ -114,7 +123,7 @@ jobs:
114123
else
115124
# Create new PR
116125
NEW_PR_URL=$(gh pr create \
117-
--repo flouthoc/buildah \
126+
--repo ${{ matrix.fork_repo }} \
118127
--draft \
119128
--base main \
120129
--head "$BRANCH_NAME" \
@@ -125,15 +134,15 @@ jobs:
125134
echo "pr_action=created" >> $GITHUB_OUTPUT
126135
fi
127136
128-
- name: 'Comment on container-libs PR with the link to buildah PR'
137+
- name: 'Comment on container-libs PR with the link to ${{ matrix.repo_name }} PR'
129138
env:
130139
GH_TOKEN: ${{ secrets.VENDOR_TOKEN_PODMANBOT }}
131140
SELF_REPO_PR_NUMBER: ${{ github.event.pull_request.number }}
132141
TARGET_REPO_PR_URL: ${{ steps.create_pr.outputs.pr_url }}
133142
PR_ACTION: ${{ steps.create_pr.outputs.pr_action }}
134143
run: |
135144
if [ "${{ env.PR_ACTION }}" = "created" ]; then
136-
COMMENT_BODY="✅ A new PR has been created in buildah to vendor these changes: **${{ env.TARGET_REPO_PR_URL }}**"
145+
COMMENT_BODY="✅ A new PR has been created in ${{ matrix.repo_name }} to vendor these changes: **${{ env.TARGET_REPO_PR_URL }}**"
137146
gh pr comment ${{ env.SELF_REPO_PR_NUMBER }} \
138147
--repo ${{ github.repository }} \
139148
--body "$COMMENT_BODY"

0 commit comments

Comments
 (0)