66jobs :
77 to_gitlab :
88 runs-on : ubuntu-latest
9- outputs :
10- success : ${{ steps.mirror.outcome == 'success' }}
119 steps :
1210 - uses : actions/checkout@v4
1311 with :
1412 fetch-depth : 0
1513
16- - name : Mirror + trigger CI
17- id : mirror
18- uses : SvanBoxel/gitlab-mirror-and-ci-action@0.6
19- timeout-minutes : 15
20- with :
21- args : " https://gitlab.desy.de/dcache/dcache"
14+ - name : Mirror to GitLab + wait for CI
2215 env :
23- FOLLOW_TAGS : " true"
24- FORCE_PUSH : " false"
25- GITLAB_HOSTNAME : " gitlab.desy.de"
26- GITLAB_USERNAME : " dcache"
2716 GITLAB_PASSWORD : ${{ secrets.GITLAB_PASSWORD }}
2817 GITLAB_PROJECT_ID : " 21"
2918 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30- POLL_TIMEOUT : 60
19+ run : |
20+ set -euo pipefail
21+ REMOTE="https://dcache:${GITLAB_PASSWORD}@gitlab.desy.de/dcache/dcache.git"
22+ git remote add mirror "$REMOTE"
3123
32- retry :
33- needs : to_gitlab
34- if : failure()
35- runs-on : ubuntu-latest
36- steps :
37- - uses : actions/checkout@v4
38- with :
39- fetch-depth : 0
24+ for attempt in 1 2 3; do
25+ echo "::group::Push attempt $attempt"
26+ git push mirror --force "HEAD:${GITHUB_REF_NAME}" && \
27+ git push mirror --tags --force-with-lease 2>&1 | grep -v "already exists" || true
28+ PUSH_EXIT=${PIPESTATUS[0]}
29+ echo "::endgroup::"
30+ [ $PUSH_EXIT -eq 0 ] && break
31+ [ $attempt -lt 3 ] && sleep $((attempt * 15)) || exit 1
32+ done
4033
41- - name : Mirror + trigger CI (retry)
42- uses : SvanBoxel/gitlab-mirror-and-ci-action@0.6
43- timeout-minutes : 15
44- with :
45- args : " https://gitlab.desy.de/dcache/dcache"
46- env :
47- FOLLOW_TAGS : " true"
48- FORCE_PUSH : " false"
49- GITLAB_HOSTNAME : " gitlab.desy.de"
50- GITLAB_USERNAME : " dcache"
51- GITLAB_PASSWORD : ${{ secrets.GITLAB_PASSWORD }}
52- GITLAB_PROJECT_ID : " 21"
53- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54- POLL_TIMEOUT : 60
34+ API="https://gitlab.desy.de/api/v4/projects/${GITLAB_PROJECT_ID}"
35+ AUTH="PRIVATE-TOKEN: ${GITLAB_PASSWORD}"
36+
37+ for i in $(seq 1 10); do
38+ PIPELINE_ID=$(curl -sf --header "$AUTH" \
39+ "${API}/pipelines?sha=${GITHUB_SHA}&order_by=id&sort=desc&per_page=1" | \
40+ python3 -c "import sys,json; p=json.load(sys.stdin); print(p[0]['id']) if p else exit(1)" 2>/dev/null) && break
41+ sleep 10
42+ done
43+
44+ echo "Pipeline: https://gitlab.desy.de/dcache/dcache/-/pipelines/${PIPELINE_ID}"
45+
46+ for i in $(seq 1 60); do
47+ STATUS=$(curl -sf --header "$AUTH" "${API}/pipelines/${PIPELINE_ID}" | \
48+ python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
49+ echo "Status: $STATUS"
50+ case "$STATUS" in
51+ success) exit 0 ;;
52+ failed|canceled|skipped) echo "::error::Pipeline $STATUS"; exit 1 ;;
53+ esac
54+ sleep 60
55+ done
56+ echo "::error::Timed out after 60 minutes"; exit 1
0 commit comments