|
| 1 | +name: CI synchronization |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + branch: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + |
| 10 | +jobs: |
| 11 | + mirror: |
| 12 | + runs-on: [self-hosted, v1] |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: analogdevicesinc/doctools/checkout@v1 |
| 16 | + |
| 17 | + - name: increase-limits |
| 18 | + run: | |
| 19 | + git config http.postBuffer 157286400 |
| 20 | +
|
| 21 | + - name: update-mirror |
| 22 | + run: | |
| 23 | + git switch -d |
| 24 | + git remote prune origin |
| 25 | + git fetch origin ${{ inputs.branch }}:${{ inputs.branch }} -f |
| 26 | + git switch ${{ inputs.branch }} |
| 27 | +
|
| 28 | + git fetch origin main --depth=1 |
| 29 | + declare -a arr=( |
| 30 | + "ci" |
| 31 | + ".github" |
| 32 | + "arch/arm/configs/adi_ci_defconfig" |
| 33 | + "arch/arm64/configs/adi_ci_defconfig" |
| 34 | + "arch/x86/configs/adi_ci_defconfig" |
| 35 | + ) |
| 36 | + for i in "${arr[@]}" |
| 37 | + do |
| 38 | + git rm -rf "$i" || true |
| 39 | + git checkout origin/main -- "$i" |
| 40 | + done |
| 41 | + commit=$(git rev-parse origin/main) |
| 42 | + git commit -m "deploy: $commit" -m "patch ci" -s |
| 43 | + echo "{{ inputs.branch }}=${{ inputs.branch }}" >> "$GITHUB_ENV" |
| 44 | +
|
| 45 | + - name: push-ci |
| 46 | + env: |
| 47 | + WORKFLOW_SECRET: ${{ secrets.WORKFLOW_SECRET}} |
| 48 | + if: ${{ env.WORKFLOW_SECRET != '' }} |
| 49 | + run: | |
| 50 | + url_=$(git remote get-url origin) |
| 51 | + url="https://x-access-token:${{ secrets.WORKFLOW_SECRET }}@github.com/${{ github.repository }}.git" |
| 52 | + git remote set-url origin "$url" |
| 53 | + git push origin ${{ inputs.branch }}:${{ inputs.branch }} -f || true |
| 54 | + git remote set-url origin "$url_" |
| 55 | +
|
| 56 | + - name: push-ci |
| 57 | + env: |
| 58 | + WORKFLOW_SECRET: ${{ secrets.WORKFLOW_SECRET}} |
| 59 | + if: ${{ env.WORKFLOW_SECRET == '' }} |
| 60 | + run: | |
| 61 | + git push origin ${{ inputs.branch }}:${{ inputs.branch }} -f |
| 62 | +
|
| 63 | + - name: unset-limits |
| 64 | + run: | |
| 65 | + git config --unset http.postBuffer |
| 66 | +
|
| 67 | + - name: clean-up |
| 68 | + if: github.event_name == 'schedule' |
| 69 | + run: | |
| 70 | + git gc --prune=now |
| 71 | +
|
| 72 | + - name: log-cached-branches |
| 73 | + run: | |
| 74 | + git --no-pager branch | cut -c 3- | \ |
| 75 | + while IFS= read -r b; do printf "$b: " ; git rev-list --count $b; done |
0 commit comments