Repository navigation
80 lines (72 loc) · 2.87 KB
/
Copy pathmirror-to-gitlab.yml
File metadata and controls
80 lines (72 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
on:
push:
branches: ['**']
tags: ['**']
release:
types: [published]
jobs:
mirror:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout (full history)
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Mirror to GitLab
env:
GITLAB_URL: ${{ secrets.GITLAB_URL }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git remote add gitlab "https://oauth2:${GITLAB_TOKEN}@${GITLAB_URL#https://}"
git push gitlab --all --force
git push gitlab --tags --force
mirror-release:
runs-on: ubuntu-latest
if: github.event_name == 'release'
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Mirror Release to GitLab
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_RELEASETOKEN }}
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ github.event.release.name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_BODY: ${{ github.event.release.body }}
RELEASE_DATE: ${{ github.event.release.published_at }}
run: |
# Release in GitLab erstellen
jq -n \
--arg name "$RELEASE_NAME" \
--arg tag "$RELEASE_TAG" \
--arg desc "$RELEASE_BODY" \
--arg date "$RELEASE_DATE" \
'{name: $name, tag_name: $tag, description: $desc, released_at: $date}' \
| curl --fail -X POST \
"https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/releases" \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
--header "Content-Type: application/json" \
--data @-
# Assets (APKs etc.) runterladen und zu GitLab hochladen
gh release download "$RELEASE_TAG" --dir ./assets
for file in ./assets/*; do
filename=$(basename "$file")
# Asset zu GitLab Package Registry hochladen
curl --fail -X PUT \
"https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/packages/generic/${RELEASE_TAG}/1.0.0/${filename}" \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
--upload-file "$file"
# Asset mit Release verknüpfen
jq -n \
--arg name "$filename" \
--arg url "https://gitlab.com/jamakr4/mg4-360-camera-app/-/package_files/generic/${RELEASE_TAG}/1.0.0/${filename}" \
'{name: $name, url: $url}' \
| curl --fail -X POST \
"https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/releases/${RELEASE_TAG}/assets/links" \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
--header "Content-Type: application/json" \
--data @-
done