|
| 1 | +name: Mirror Repository |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +# Concurrency control to prevent parallel runs |
| 9 | +concurrency: |
| 10 | + group: premerge-mirror-verification-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + mirror-repository: |
| 18 | + runs-on: self-hosted |
| 19 | + container: |
| 20 | + image: docker:dind |
| 21 | + timeout-minutes: 30 |
| 22 | + # Only run on specific repository and specific PRs |
| 23 | + if: github.repository == 'isaac-sim/IsaacLab' && github.event.pull_request.base.ref == 'main' |
| 24 | + environment: |
| 25 | + name: mirror-production |
| 26 | + url: https://github.com/${{ vars.TARGET_REPO }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Install Git LFS |
| 30 | + run: | |
| 31 | + apk update |
| 32 | + apk add --no-cache git-lfs |
| 33 | + git lfs install |
| 34 | +
|
| 35 | + - name: Checkout Code |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + lfs: true |
| 40 | + |
| 41 | + - name: Configure Git |
| 42 | + run: | |
| 43 | + git config --global user.name "Isaac LAB CI Bot" |
| 44 | + git config --global user.email "isaac-lab-ci-bot@nvidia.com" |
| 45 | +
|
| 46 | + - name: Mirror to Target Repository |
| 47 | + run: | |
| 48 | + git config --global --add safe.directory ${{ github.workspace }} |
| 49 | + git config --global --add safe.directory . |
| 50 | +
|
| 51 | + # Test different repository name variations |
| 52 | + echo "🔍 Testing repository access..." |
| 53 | + |
| 54 | + # Test the current repository name |
| 55 | + REPO_URL="https://github.com/${{ vars.TARGET_REPO }}.git" |
| 56 | + REPO_URL="${REPO_URL%/}" |
| 57 | + |
| 58 | +
|
| 59 | + # Set the target repository as origin (like CodeBuild does) |
| 60 | + git remote set-url origin "$REPO_URL" |
| 61 | + |
| 62 | + # Create PR branch name for verification |
| 63 | + PR_BRANCH_NAME="pr-${{ github.event.number }}-${{ github.head_ref }}" |
| 64 | + |
| 65 | + # Create a temporary branch with the PR changes |
| 66 | + git checkout -b $PR_BRANCH_NAME |
| 67 | + |
| 68 | + # Push the temporary branch to the target repository for verification |
| 69 | + git push --force "https://${{ secrets.GH_TOKEN }}@github.com/${{ vars.TARGET_REPO }}.git" "$PR_BRANCH_NAME" |
| 70 | +
|
| 71 | + echo "✅ Successfully pushed PR verification branch to ${{ vars.TARGET_REPO }}:$PR_BRANCH_NAME" |
| 72 | + echo "PR Number: ${{ github.event.number }}" |
| 73 | + echo "PR Head Branch: ${{ github.head_ref }}" |
0 commit comments