Skip to content

Commit 1bbeda2

Browse files
committed
wip: add web-downloader
1 parent 94a1517 commit 1bbeda2

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

web-downloader/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.env.default

web-downloader/compose.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
web-downloader-track:
3+
image: alpine
4+
command: /home/docker/web-downloader/web-downloader.sh
5+
environment:
6+
- TEAMCITY_TAG=${TRACK_WEB_VERSION:?required}
7+
- TEAMCITY_BUILD_NAME=MaintainVbenAdmin_Release
8+
- TEAMCITY_BUILD_ZIP_NAME=maintain.zip
9+
- NGINX_HTML_DIR_NAME=track
10+
volumes:
11+
- "${DATA_DIR:-/data}/nginx/html:/data/nginx/html"
12+
configs:
13+
- source: web-downloader.sh
14+
target: /home/docker/web-downloader/web-downloader.sh
15+
- source: teamcity-download-artifact.sh
16+
target: /home/docker/projects/teamcity-download-artifact.sh
17+
18+
configs:
19+
web-downloader.sh:
20+
file: ./web-downloader.sh
21+
teamcity-download-artifact.sh:
22+
file: ../projects/teamcity-download-artifact.sh

web-downloader/web-downloader.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ -z "${TEAMCITY_BUILD_NAME}" ]; then
5+
echo "Please set these environment variables:"
6+
echo "TEAMCITY_BUILD_NAME, TEAMCITY_TAG, TEAMCITY_BUILD_ZIP_NAME, NGINX_HTML_DIR_NAME"
7+
exit 1
8+
fi
9+
10+
cd /data/nginx/html || exit 1
11+
12+
version_file="${NGINX_HTML_DIR_NAME}/.version"
13+
14+
# Check if the version already exists
15+
if [ -f "$version_file" ]; then
16+
current_version=$(cat "$version_file")
17+
if [ "$current_version" = "${TEAMCITY_TAG}" ]; then
18+
echo "Version ${TEAMCITY_TAG} already exists"
19+
exit 0
20+
fi
21+
fi
22+
23+
# Remove the existing directory
24+
if [ -e "${NGINX_HTML_DIR_NAME}" ]; then
25+
rm -rf "${NGINX_HTML_DIR_NAME}"
26+
fi
27+
28+
# Download the new version
29+
/home/docker/projects/teamcity-download-artifact.sh --build="${TEAMCITY_BUILD_NAME}" --tag="${TEAMCITY_TAG}"
30+
unzip "${TEAMCITY_BUILD_NAME}-${TEAMCITY_TAG}.zip"
31+
unzip "${TEAMCITY_BUILD_ZIP_NAME}" -d "${NGINX_HTML_DIR_NAME}"
32+
33+
# Clean up
34+
rm -f "${TEAMCITY_BUILD_ZIP_NAME}"
35+
# rm "${TEAMCITY_BUILD_NAME}-${TEAMCITY_TAG}.zip"
36+
echo "${TEAMCITY_TAG}" > "$version_file"

0 commit comments

Comments
 (0)