Newer
Older

Griefed
committed
stages:

Griefed
committed
- docs

Griefed
committed
- name: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.12

Griefed
committed

Griefed
committed
image: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.12
workflow:
rules:
- if: '$CI_MERGE_REQUEST_EVENT_TYPE == "detached"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: always

Griefed
committed
test quasar:
stage: test
cache:
paths:
- node_modules/
before_script:
- npm install
- rm -Rf dist
script:
- quasar build
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
test docker:
stage: test
variables:
project_name: $CI_PROJECT_NAME
SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
before_script:
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use --name grfdbuilder
script:
- docker buildx build --no-cache --platform linux/amd64,linux/arm/v7,linux/arm64
--build-arg BRANCH_OR_TAG=$CI_COMMIT_REF_NAME
--build-arg HOSTER=$CI_SERVER_HOST
--file Dockerfile .
rules:
- if: '$CI_SERVER_HOST == "git.griefed.de"'
release:
needs: ['test docker','test quasar']
stage: release
variables:
project_name: $CI_PROJECT_NAME
SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
script:
- npx semantic-release
only:
- master
except:
refs:
- tags
variables:
- $CI_COMMIT_TITLE =~ /^RELEASE:.+$/
build:
stage: build
variables:
project_name: $CI_PROJECT_NAME
SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
before_script:
- docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_TOKEN" docker.io
- docker login -u "$DOCKERHUB_USER" -p "$GITHUB_TOKEN" ghcr.io
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use --name grfdbuilder
script:
- docker buildx build
--push
--no-cache
--platform linux/amd64,linux/arm/v7,linux/arm64
--build-arg BRANCH_OR_TAG=$CI_COMMIT_REF_NAME
--build-arg HOSTER=$CI_SERVER_HOST
--tag "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:$CI_COMMIT_TAG"
--tag "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:latest"
--tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:$CI_COMMIT_TAG"
--tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:latest"
--file Dockerfile .
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/ && $CI_SERVER_HOST == "git.griefed.de"'

Griefed
committed
pages:

Griefed
committed
cache:
paths:
- node_modules/
before_script:
- npm install
- rm -Rf dist
script:
- quasar build
- cp -Rf dist/spa/* public/
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
expire_in: 1 week
Check Packages:on-schedule:
only:
- schedules
before_script:
- |-
echo "Preparing package versions comparison."
# Check and, if necessary, update git user and mail
if [[ "$(git config --list | grep user.name)" != "user.name=$GIT_USER" ]];then
git config --global user.name $GIT_USER
fi
if [[ "$(git config --list | grep user.email)" != "user.email=$GIT_MAIL" ]];then
git config --global user.email $GIT_MAIL
fi
# Clean system of potentially interrupting images
docker image rm -f $DOCKERHUB_USER/$DOCKERHUB_REPO:latest
docker image rm -f $DOCKERHUB_REPO
rm -rf /tmp/$CI_PROJECT_PATH
mkdir -p /tmp/$CI_PROJECT_PATH
echo "Preparations complete."
script:
- |-
echo "Comparing package versions." && \
# Clone the repository
git clone $CI_PROJECT_URL.git /tmp/$CI_PROJECT_PATH && \
cd /tmp/$CI_PROJECT_PATH && \
if [ ! -s "package_versions.txt" ];then
echo "No package_versions.txt available..." && \
# Gather package information from latest build
docker run --rm --entrypoint /bin/sh -v /tmp/$CI_PROJECT_PATH:/tmp $DOCKERHUB_USER/$DOCKERHUB_REPO:latest -c '\
apk info -v > /tmp/package_versions.txt && \
sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \
chmod 777 /tmp/package_versions.txt' && \
# Checkout our branch
git checkout -f $CI_DEFAULT_BRANCH && \
wait && \
# Add and commit new file to repository
git add package_versions.txt && \
git commit -m 'chore: Add list of package versions.' && \
# Push the changes to the remote
git push "https://$GIT_USER:$GITLAB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" --all && \
# Nice
echo "package_versions.txt added."
elif [ -s "package_versions.txt" ];then
echo "Local package_versions.txt available..." && \
# Build local image for new package versions list
docker build --no-cache --tag $DOCKERHUB_REPO . && \
# Get packages from newly build local image
docker run --rm --entrypoint /bin/sh -v /tmp/$CI_PROJECT_PATH:/tmp $DOCKERHUB_REPO -c '\
apk info -v > /tmp/package_versions_new.txt && \
sort -o /tmp/package_versions_new.txt /tmp/package_versions_new.txt && \
chmod 777 /tmp/package_versions_new.txt' && \
# Get checksum of old packages
OLD_CHECKSUM=$(md5sum package_versions.txt | cut -f1 -d" ") && \
# Get checksum of new packages
NEW_CHECKSUM=$(md5sum package_versions_new.txt | cut -f1 -d" ")
# If new checksum is not the same as old checksum, we have new versions
if [ "${OLD_CHECKSUM}" != "${NEW_CHECKSUM}" ]; then
echo "Checksums differ. Updating..." && \
# Checkout our branch
git checkout -f $CI_DEFAULT_BRANCH && \
# Copy the new package versions list to repository
mv -f package_versions_new.txt package_versions.txt && \
wait && \
# Add and commit new file to repository
git add package_versions.txt && \
git commit -m 'build: Update installed packages in Docker container.' && \
# Push the changes to the remote
git push "https://$GIT_USER:$GITLAB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" --all && \
# Nice
echo "Packages updated."
else
echo "No package updates available."
fi
fi
echo "Comparison complete."
after_script:
- |-
echo "Cleaning up."
docker image rm -f $DOCKERHUB_USER/$DOCKERHUB_REPO:latest
docker image rm -f $DOCKERHUB_REPO
rm -rf /tmp/$CI_PROJECT_PATH
echo "Done."