chore: Only push versioned docker image on tag builds.

This commit is contained in:
iphydf 2021-12-23 16:12:22 +00:00
parent 1e11865c4c
commit 1639703c62
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 46 additions and 31 deletions

View File

@ -44,17 +44,3 @@ jobs:
- uses: actions/checkout@v2
- name: Build on FreeBSD
run: .travis/cmake-freebsd-stage2
build-bootstrap-docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- uses: actions/checkout@v2
- name: Docker Build
run: .travis/tox-bootstrapd-docker
- name: Push images to DockerHub
if: ${{ github.event_name == 'push' }}
run: |
docker push toxchat/bootstrap-node:latest
docker push toxchat/bootstrap-node:"$(other/print-version)"

23
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: docker
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build-bootstrap-docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- uses: actions/checkout@v2
- name: Docker Build
run: .travis/tox-bootstrapd-docker local
- name: Push latest image to DockerHub
if: ${{ github.event_name == 'push' }}
run: docker push toxchat/bootstrap-node:latest
- name: Push versioned image to DockerHub
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
run: docker push toxchat/bootstrap-node:"$(other/print-version)"

View File

@ -2,9 +2,13 @@
set -exu
LOCAL="${1:-}"
readarray -t FILES <<<"$(git ls-files)"
tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
docker tag toxchat/bootstrap-node:latest toxchat/bootstrap-node:"$(other/print-version)"
sudo useradd \
--home-dir /var/lib/tox-bootstrapd \
--create-home \
@ -30,24 +34,28 @@ if sudo [ ! -f /var/lib/tox-bootstrapd/keys ]; then
exit 1
fi
COUNTER=0
COUNTER_END=120
while [ "$COUNTER" -lt "$COUNTER_END" ]; do
if docker logs tox-bootstrapd | grep -q "Connected to another bootstrap node successfully"; then
break
if [ "$LOCAL" != "local" ]; then
COUNTER=0
COUNTER_END=120
while [ "$COUNTER" -lt "$COUNTER_END" ]; do
if docker logs tox-bootstrapd | grep -q "Connected to another bootstrap node successfully"; then
break
fi
sleep 1
COUNTER=$(($COUNTER + 1))
done
docker logs tox-bootstrapd
if [ "$COUNTER" = "$COUNTER_END" ]; then
echo "Error: Didn't connect to any nodes"
exit 1
fi
sleep 1
COUNTER=$(($COUNTER + 1))
done
docker logs tox-bootstrapd
if [ "$COUNTER" = "$COUNTER_END" ]; then
echo "Error: Didn't connect to any nodes"
exit 1
else
docker logs tox-bootstrapd
fi
# Wait a bit befrore testing if the container is still running
# Wait a bit before testing if the container is still running
sleep 30
docker ps -a
@ -67,5 +75,3 @@ if ! other/fun/bootstrap_node_info.py ipv4 localhost 33445; then
echo "Error: Unable to get bootstrap node info"
exit 1
fi
docker tag toxchat/bootstrap-node:latest toxchat/bootstrap-node:"$(other/print-version)"