-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
89 lines (78 loc) · 2.61 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
89 lines (78 loc) · 2.61 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
80
81
82
83
84
85
86
87
88
89
stages:
- build
- index
- deploy
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_UPDATE_FLAGS: --remote --merge
LIBRARY_BRANCH: library
# Build the hydrogen-index tool from the submodule
build-indexer:
stage: build
image: golang:1.26
script:
- cd hydrogen-index
- go build -o ../hydrogen-index-cli .
- cd ..
artifacts:
paths:
- hydrogen-index-cli
expire_in: 1 hour
# Generate the index.json file with all artifact metadata
generate-index:
stage: index
image: golang:1.26
needs:
- build-indexer
before_script:
- apt update && apt install -y jq
script:
# Get the repository path in GitLab format (namespace/project)
- REPO_PATH="${CI_PROJECT_PATH}"
- echo "Repository path [${REPO_PATH}]"
# Run hydrogen-index to scan artifacts and generate index.json
# The tool will auto-detect the git root and scan for .h2drumkit, .h2pattern, .h2song files
- ./hydrogen-index-cli scan \
--provider gitlab \
--repo "${REPO_PATH}" \
--branch "${LIBRARY_BRANCH}" \
--output index.json \
--exclude hydrogen-index
# Validate the generated index
- ./hydrogen-index-cli validate index.json
# Display summary
- echo "Index generation complete. Summary:"
- cat index.json | jq '{version, patternCount, songCount, drumkitCount, generatedAt}'
artifacts:
paths:
- index.json
expire_in: 1 hour
# Deploy the index.json to the library branch
deploy-index:
stage: deploy
image: alpine:latest
needs:
- generate-index
before_script:
# Install git and configure
- apk add --no-cache git
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
script:
# Clone the repository with the library branch
- git clone --depth 1 --branch "${LIBRARY_BRANCH}" "${CI_REPOSITORY_URL}" deploy-repo || git clone --depth 1 "${CI_REPOSITORY_URL}" deploy-repo
- cd deploy-repo
- git remote set-url origin "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
# If library branch doesn't exist, create it
- git checkout "${LIBRARY_BRANCH}" 2>/dev/null || git checkout -b "${LIBRARY_BRANCH}"
# Copy the generated index.json
- cp ../index.json .
# Commit and push the changes
- git add index.json
- git commit -m "Update index.json [skip ci]" || echo "No changes to commit"
- git push origin "HEAD:${LIBRARY_BRANCH}"
- echo "Index deployed to ${LIBRARY_BRANCH} branch"
- echo "Permalink [${CI_PROJECT_URL}/-/raw/${LIBRARY_BRANCH}/index.json]"
only:
- main
- master