Skip to content

Added manual workflow to create PRs merging default branch into "rele… #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/merge-default-branch-into-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Extract Repos and Create PRs

on:
workflow_dispatch:

jobs:
extract-and-create-prs:
runs-on: ubuntu-latest
steps:
- name: Fetch and extract data
id: extract
run: |
# Fetch the raw file content
content=$(curl -s https://raw.githubusercontent.com/mage-os/generate-mirror-repo-js/refs/heads/main/src/build-config/mageos-nightly-build-config.js)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we haven't been maintaining the nightly builds for a long time now, I think it may be better to use another one instead, that is, https://github.com/mage-os/generate-mirror-repo-js/blob/main/src/build-config/mageos-release-build-config.js


# Extract repoUrl and ref and store in a temporary file
echo "$content" | grep -E "repoUrl:|ref:" | awk -F"'" '{print $2}' | paste - - > repos_and_refs.txt

# Display what we found
echo "Extracted repositories and refs:"
cat repos_and_refs.txt

- name: Create PRs for each repository
env:
GITHUB_TOKEN: ${{ secrets.MAGE_OS_CI_TOKEN }}
run: |
# Read the temporary file line by line
while read -r repo ref; do
echo "Processing repository: $repo"
echo "Branch to merge: $ref"

# Extract owner and repo name from the URL
repo_path=$(echo $repo | sed 's/https:\/\/github.com\///' | sed 's/\.git$//')
owner=$(echo $repo_path | cut -d'/' -f1)
repo_name=$(echo $repo_path | cut -d'/' -f2)

# Create a PR using GitHub CLI
echo "Creating PR to merge $ref into release/1.x for $repo_name"

# Use GitHub CLI to create the PR
# Note: This requires a properly scoped token with permissions to create PRs
gh pr create \
--repo $repo_path \
--base "release/1.x" \
--head "$ref" \
--title "Merge $ref into release/1.x" \
--body "This PR was automatically created to merge the $ref branch into the release/1.x branch."

echo "---"
done < repos_and_refs.txt