diff --git a/.github/workflows/docker-image-build.yml b/.github/workflows/docker-image-build.yml new file mode 100644 index 00000000..64ccaa17 --- /dev/null +++ b/.github/workflows/docker-image-build.yml @@ -0,0 +1,24 @@ +name: Build docker image + +on: + push: + branches: + - develop + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Install buildx + id: buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + buildx-version: latest + - name: Login to docker hub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + - name: Build the image + run: bash ./docker/build diff --git a/.travis.yml b/.travis.yml index e2d901d1..c36f9984 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,14 +18,6 @@ jobs: allow_failures: - php: 'nightly' include: - - name: "Docker publish" - if: NOT type = pull_request - # Overwrite all common steps that have to be different - before_install: echo "Before install" - install: sudo ./data/infra/ci/install-docker.sh - before_script: echo "Before script" - script: bash ./docker/build - after_success: echo "After success" - name: "CI - 8.0" php: 'nightly' env: @@ -47,7 +39,6 @@ jobs: on: tags: true -# Common steps for all jobs before_install: - echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - phpenv config-rm xdebug.ini || return 0 diff --git a/data/infra/ci/install-docker.sh b/data/infra/ci/install-docker.sh deleted file mode 100755 index 58289a16..00000000 --- a/data/infra/ci/install-docker.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -# install latest docker version -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -apt-get update -apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - -# enable multiarch execution -docker run --rm --privileged multiarch/qemu-user-static --reset -p yes diff --git a/docker/build b/docker/build index a2855fdf..0302d607 100755 --- a/docker/build +++ b/docker/build @@ -2,33 +2,23 @@ set -e -# PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64" -PLATFORMS="linux/amd64" -DOCKER_IMAGE="shlinkio/shlink" -BUILDX_VER=v0.4.1 -export DOCKER_CLI_EXPERIMENTAL=enabled +PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64" +# PLATFORMS="linux/amd64" +DOCKER_IMAGE="shlinkio/lab" -mkdir -vp ~/.docker/cli-plugins/ ~/dockercache -curl --silent -L "https://github.com/docker/buildx/releases/download/${BUILDX_VER}/buildx-${BUILDX_VER}.linux-amd64" > ~/.docker/cli-plugins/docker-buildx -chmod a+x ~/.docker/cli-plugins/docker-buildx - -docker buildx create --use - -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - -# If there is a tag, regardless the branch, build that docker tag and also "stable" -if [[ ! -z $TRAVIS_TAG ]]; then - TAGS="-t ${DOCKER_IMAGE}:${TRAVIS_TAG#?}" +# If ref is not develop, then this is a tag. Build that docker tag and also "stable" +if [[ "$GITHUB_REF" != *"develop"* ]]; then + TAGS="-t ${DOCKER_IMAGE}:${GITHUB_REF#?}" # Push stable tag only if this is not an alpha or beta tag - [[ $TRAVIS_TAG != *"alpha"* && $TRAVIS_TAG != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable" + [[ $GITHUB_REF != *"alpha"* && $GITHUB_REF != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable" docker buildx build --push \ - --build-arg SHLINK_VERSION=${TRAVIS_TAG#?} \ + --build-arg SHLINK_VERSION=${GITHUB_REF#?} \ --platform ${PLATFORMS} \ ${TAGS} . -# If build branch is develop, build latest (on main branch, when there's no tag, do not build anything) -elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then +# If build branch is develop, build latest +elif [[ "$GITHUB_REF" == *"develop"* ]]; then docker buildx build --push \ --platform ${PLATFORMS} \ -t ${DOCKER_IMAGE}:latest .