[PATCH] D156873: [Workflow] Run the repository sync script from GH.

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 00:01:43 PDT 2023


thieta edited the summary of this revision.
thieta updated this revision to Diff 548890.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156873/new/

https://reviews.llvm.org/D156873

Files:
  .github/workflows/sync-release-repo.yml
  llvm/utils/git/sync-release-repo.sh


Index: llvm/utils/git/sync-release-repo.sh
===================================================================
--- llvm/utils/git/sync-release-repo.sh
+++ llvm/utils/git/sync-release-repo.sh
@@ -20,13 +20,16 @@
 MAIN_REMOTE=$(uuidgen)
 RELEASE_REMOTE=$(uuidgen)
 CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+# depth here must make sure to fetch enough history to make a merge,
+# it's an arbritary value at this point. Consider using --shallow-since=
+FETCH_OPTIONS="--prune --no-tags --progress --depth=100"
 
 git remote add $MAIN_REMOTE "https://github.com/llvm/llvm-project"
-git remote add $RELEASE_REMOTE "https://github.com/llvm/llvm-project-release-prs"
+git remote add $RELEASE_REMOTE "https://token:$GH_TOKEN@github.com/llvm/llvm-project-release-prs"
 
 # Make sure we are up to date on all our repos first
-git fetch $MAIN_REMOTE
-git fetch $RELEASE_REMOTE
+git fetch $FETCH_OPTIONS $MAIN_REMOTE $RELEASE_BRANCH
+git fetch $FETCH_OPTIONS $RELEASE_REMOTE $RELEASE_BRANCH
 
 # Create our sync branch. Starting with the main
 # repo first since it's important to get those
@@ -49,8 +52,8 @@
 # the real solution would instead be to fetch
 # in a loop if pushing fails. But that's a very
 # tiny edge-case, so let's not complicate this.
-git fetch $MAIN_REMOTE
-git fetch $RELEASE_REMOTE
+git fetch $FETCH_OPTIONS $MAIN_REMOTE $RELEASE_BRANCH
+git fetch $FETCH_OPTIONS $RELEASE_REMOTE $RELEASE_BRANCH
 
 # And merge all the new data to the current branch
 git merge --ff-only $MAIN_REMOTE/$RELEASE_BRANCH
@@ -58,6 +61,9 @@
 # If anything changed let's merge it
 if ! git diff-index --quiet $RELEASE_REMOTE/$RELEASE_BRANCH; then
   echo "Changes in main - pushing to release"
+  # Remove the token stored by GH Actions, otherwise it
+  # won't use our own token in $GH_TOKEN
+  git config --unset-all http.https://github.com/.extraheader
   git push $RELEASE_REMOTE $MERGE_BRANCH:$RELEASE_BRANCH
 fi
 
Index: .github/workflows/sync-release-repo.yml
===================================================================
--- /dev/null
+++ .github/workflows/sync-release-repo.yml
@@ -0,0 +1,17 @@
+name: Sync Release Repositories
+permissions:
+  contents: write
+on:
+  workflow_dispatch
+env:
+  RELEASE_BRANCH: release/17.x
+  GH_TOKEN: ${{ secrets.RELEASE_WORKFLOW_PUSH_SECRET }}
+jobs:
+  sync:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Fetch LLVM sources
+        uses: actions/checkout at v3
+      - name: Run Sync Script
+        run: |
+          llvm/utils/git/sync-release-repo.sh


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156873.548890.patch
Type: text/x-patch
Size: 2510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/b184ee46/attachment.bin>


More information about the llvm-commits mailing list