Update zwift_push.yaml #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Zwift script files updater | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
zwift_push: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 60 | |
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" | |
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 | |
docker rm zwift | |
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 |