Skip to content

Commit

Permalink
enable dev branch push, push on same version when non cron
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio Gutierrez committed Mar 23, 2020
1 parent 245aed9 commit 6e55b46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ env:
- ARCH=armv7hf

before_script:
- nordvpn_version=$(curl https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/ | grep amd64.deb | sed 's/\(<a.*nordvpn_\)\([0-9.-]\+\).*/\2/' | sort | uniq | tail -n 1)
- docker_version=$(curl -sSL "https://registry.hub.docker.com/v2/repositories/$REPO/tags?page_size=1024" | jq -r '."results"[]["name"]' | grep '^[0-9].*[0-9]$' | sort | uniq | tail -n 1)
- if [ "${nordvpn_version}" == "${docker_version}" ]; then exit 0 ; fi
- DOCKER_VERSION=$(curl -sSL "https://registry.hub.docker.com/v2/repositories/$REPO/tags?page_size=1024" | jq -r '."results"[]["name"]' | grep '^[0-9].*[0-9]$' | sort | uniq | tail -n 1)
- NORDVPN_VERSION=$(curl https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/ | grep amd64.deb | sed 's/\(<a.*nordvpn_\)\([0-9.-]\+\).*/\2/' | sort | uniq | tail -n 1)
- if [ "${TRAVIS_EVENT_TYPE}" == "cron" && "${NORDVPN_VERSION}" == "${DOCKER_VERSION}" ]; then exit 0 ; fi
- VERSION="${NORDVPN_VERSION}" ; BRANCH="latest"
- if [ "${TRAVIS_BRANCH}" != "master" ]; then VERSION+="${TRAVIS_BRANCH}" ; BRANCH="${TRAVIS_BRANCH}" ; fi
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- if [ "${ARCH}" == "armv7hf" ]; then sed -i 's/^#CROSSRUN/RUN/g' Dockerfile ; fi

stage: "Build"
script:
- docker build --build-arg ARCH=${ARCH} --build-arg VERSION=${nordvpn_version} -t $REPO:${ARCH}-${nordvpn_version} .
- docker push $REPO:${ARCH}-${nordvpn_version}
- docker tag $REPO:${ARCH}-${nordvpn_version} $REPO:${ARCH}-latest
- docker push $REPO:${ARCH}-latest
- docker build --build-arg ARCH=${ARCH} --build-arg NORDVPN_VERSION=${NORDVPN_VERSION} -t $REPO:${ARCH}-${VERSION} .
- docker push $REPO:${ARCH}-${VERSION}
- docker tag $REPO:${ARCH}-${VERSION} $REPO:${ARCH}-${BRANCH}
- docker push $REPO:${ARCH}-${BRANCH}

jobs:
fast_finish: true
Expand All @@ -43,5 +45,5 @@ jobs:
docker manifest annotate $REPO:${1} $REPO:armv7hf-${1} --os linux --arch arm --variant v7
docker manifest push --purge $REPO:${1}
}
- push ${nordvpn_version}
- push latest
- push ${VERSION}
- push ${BRANCH}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG ARCH=amd64
FROM balenalib/${ARCH}-ubuntu

ARG VERSION
ARG NORDVPN_VERSION
LABEL maintainer="Julio Gutierrez"

HEALTHCHECK --interval=1m --timeout=5s --start-period=1m \
Expand All @@ -15,7 +15,7 @@ RUN addgroup --system vpn && \
apt-get update && apt-get upgrade -y && \
apt-get install -y wget dpkg curl gnupg2 jq && \
wget -nc https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && dpkg -i nordvpn-release_1.0.0_all.deb && \
apt-get update && apt-get install -yqq nordvpn${VERSION:+=$VERSION} || sed -i "s/init)/$(ps --no-headers -o comm 1))/" /var/lib/dpkg/info/nordvpn.postinst && \
apt-get update && apt-get install -yqq nordvpn${NORDVPN_VERSION:+=$NORDVPN_VERSION} || sed -i "s/init)/$(ps --no-headers -o comm 1))/" /var/lib/dpkg/info/nordvpn.postinst && \
apt-get install -yqq && apt-get clean && \
rm -rf \
./nordvpn* \
Expand Down

0 comments on commit 6e55b46

Please sign in to comment.