Skip to content

Synchronize Release Subtrees #1577

Synchronize Release Subtrees

Synchronize Release Subtrees #1577

name: Synchronize Release Subtrees
on:
workflow_dispatch:
schedule:
- cron: '15 * * * *'
env:
SUPER_REPO_URL: github.com/ROCm/rocm-systems.git
SUPER_REPO_BRANCH: release/rocm-rel-7.0
concurrency:
group: pr-update-subtrees-release
cancel-in-progress: false
jobs:
synchronize-subtrees:
if: github.repository == 'ROCm/rocm-systems'
runs-on: ubuntu-24.04
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout the Super-repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # needed for git subtree pull/push
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ env.SUPER_REPO_BRANCH }}
- name: Set up Git user
run: |
git config user.name "systems-assistant[bot]"
git config user.email "systems-assistant[bot]@users.noreply.github.com"
- name: Switch to the Super-repo branch
run: |
git checkout -B "${{ env.SUPER_REPO_BRANCH }}" "origin/${{ env.SUPER_REPO_BRANCH }}"
- name: Update Repositories in the Super-repo
run: |
has_errors=false
for repo in $(cat .github/repos-config-release.json | jq -r '.repositories[].name'); do
url=$(cat .github/repos-config-release.json | jq -r ".repositories[] | select(.name == \"$repo\") | .url")
branch=$(cat .github/repos-config-release.json | jq -r ".repositories[] | select(.name == \"$repo\") | .branch")
category=$(cat .github/repos-config-release.json | jq -r ".repositories[] | select(.name == \"$repo\") | .category")
enable_pull=$(cat .github/repos-config-release.json | jq -r ".repositories[] | select(.name == \"$repo\") | .auto_subtree_pull")
enable_push=$(cat .github/repos-config-release.json | jq -r ".repositories[] | select(.name == \"$repo\") | .auto_subtree_push")
if [ "$enable_pull" = true ]; then
git subtree pull --prefix "${category}/${repo}" https://github.com/${url}.git $branch || {
has_errors=true
}
fi
# if [ "$enable_push" = true ]; then
# git fetch origin subtrees/${repo}/${branch}
# git branch -f subtrees/${repo}/${branch} origin/subtrees/${repo}/${branch}
# git subtree split --prefix="${category}/${repo}" -b subtrees/${repo}/${branch} --quiet --rejoin || {
# has_errors=true
# }
# git push origin subtrees/${repo}/${branch}
# git push https://github.com/${url}.git subtrees/${repo}/${branch}:${branch}
# fi
done
if [ "$has_errors" = true ]; then
echo "One or more errors occurred during the repository update."
exit 1
else
git push https://${{ env.SUPER_REPO_URL }} ${{ env.SUPER_REPO_BRANCH }}
echo "All repositories updated successfully!"
fi