-
-
Notifications
You must be signed in to change notification settings - Fork 32
56 lines (48 loc) · 1.8 KB
/
zwift_push.yaml
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
name: Zwift script files updater
on:
push:
branches:
- master
jobs:
zwift_push:
runs-on: ubuntu-22.04
timeout-minutes: 60
concurrency: zwift
steps:
- uses: netbrain/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
- name: Get latest zwift container and diff script files
run: |
set -x
docker pull netbrain/zwift:latest
docker create --name zwift netbrain/zwift:latest
declare -A files_map
files_map["/bin/entrypoint"]="entrypoint.sh"
files_map["/bin/zwift-auth"]="zwift-auth.sh"
files_map["/bin/update_zwift.sh"]="update_zwift.sh"
files_map["/bin/run_zwift.sh"]="run_zwift.sh"
has_changes=false
for container_path in "${!files_map[@]}"; do
local_file="${files_map[${container_path}]}"
docker cp "zwift:${container_path}" "/tmp/${local_file}"
diff_exit_code=$(diff "${local_file}" "/tmp/${local_file}" > /dev/null; echo $?)
if [[ $diff_exit_code -eq 1 ]]; then
has_changes=true
docker cp "${local_file}" "zwift:${container_path}"
fi
done
if [ "$has_changes" = true ]; then
export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
docker commit --change="LABEL org.opencontainers.image.created=$BUILD_DATE" \
-m "Updated script files from git ($GITHUB_SHA)" \
zwift \
netbrain/zwift:latest
docker push "netbrain/zwift:latest"
fi
docker rm zwift