File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Mirror GitLab Release
2+
3+ on :
4+ push :
5+ tags :
6+ - " v*"
7+
8+ permissions :
9+ contents : write
10+
11+ jobs :
12+ mirror-release :
13+ runs-on : ubuntu-latest
14+ env :
15+ GITLAB_PROJECT : uniget-org/cli
16+ GITLAB_PROJECT_API : uniget-org%2Fcli
17+ GITLAB_REPO_URL : https://gitlab.com/${GITLAB_PROJECT}
18+ GITLAB_RELEASE_API_URL : https://gitlab.com/${GITLAB_PROJECT}/-/releases/${GITHUB_REF_NAME}
19+ GITLAB_PROJECT_API_URL : " https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_API}/releases/${GITHUB_REF_NAME}"
20+ steps :
21+ - name : Mirror release from GitLab
22+ shell : bash
23+ run : |
24+ set -euo pipefail
25+
26+ echo "Fetching GitLab release for tag: ${GITHUB_REF_NAME}"
27+ if ! curl --silent --show-error --location --fail --output release.json "${GITLAB_PROJECT_API_URL}"; then
28+ echo "ERROR: Failed to fetch GitLab release for tag >${GITHUB_REF_NAME}>."
29+ exit 1
30+ fi
31+
32+ title="$(jq -r '.name // .tag_name' release.json)"
33+ notes_file=release_notes.md
34+ {
35+ echo "Mirrored from GitLab: ${GITLAB_RELEASE_API_URL}"
36+ echo
37+ jq -r '.description // ""' release.json
38+ } >"${notes_file}"
39+
40+ if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
41+ echo "Updating existing GitHub release ${GITHUB_REF_NAME}"
42+ gh release edit "${GITHUB_REF_NAME}" --title "${title}" --notes-file "${notes_file}"
43+ else
44+ echo "Creating GitHub release ${GITHUB_REF_NAME}"
45+ gh release create "${GITHUB_REF_NAME}" --title "${title}" --notes-file "${notes_file}"
46+ fi
You can’t perform that action at this time.
0 commit comments