Switch to GitHub Actions
Stop publishing Docker image on Quay
This commit is contained in:
parent
3471f7d26d
commit
5fc3fa53b5
@ -3,12 +3,11 @@
|
||||
/*.iml
|
||||
|
||||
/.git
|
||||
/.github
|
||||
/.res
|
||||
/examples
|
||||
/.editorconfig
|
||||
/.gitignore
|
||||
/.travis.yml
|
||||
/build.sh
|
||||
/CHANGELOG.md
|
||||
/LICENSE
|
||||
/README.md
|
||||
|
78
.github/workflows/build.yml
vendored
Normal file
78
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: 'master'
|
||||
push:
|
||||
branches: 'master'
|
||||
tags: '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Prepare
|
||||
id: prepare
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
echo ::set-output name=tag_name::${TAG}
|
||||
echo ::set-output name=version::${TAG%-*}
|
||||
else
|
||||
echo ::set-output name=version::snapshot
|
||||
fi
|
||||
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
echo ::set-output name=docker_platforms::linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
|
||||
echo ::set-output name=docker_username::crazymax
|
||||
echo ::set-output name=docker_image::crazymax/jetbrains-license-server
|
||||
-
|
||||
# https://github.com/crazy-max/ghaction-docker-buildx
|
||||
name: Set up Docker Buildx
|
||||
uses: crazy-max/ghaction-docker-buildx@v1
|
||||
with:
|
||||
version: latest
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
-
|
||||
name: Docker Buildx (no push)
|
||||
run: |
|
||||
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
|
||||
--output "type=image,push=false" \
|
||||
--label "org.label-schema.build-date=${{ steps.prepare.outputs.build_date }}" \
|
||||
--label "org.label-schema.version=${{ steps.prepare.outputs.version }}" \
|
||||
--label "org.label-schema.vcs-ref=${GITHUB_SHA::8}" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \
|
||||
--file Dockerfile .
|
||||
-
|
||||
name: Docker Login
|
||||
if: success() && startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: |
|
||||
echo "${DOCKER_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin
|
||||
-
|
||||
name: Docker Buildx (push)
|
||||
if: success() && startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
|
||||
--output "type=image,push=true" \
|
||||
--label "org.label-schema.build-date=${{ steps.prepare.outputs.build_date }}" \
|
||||
--label "org.label-schema.version=${{ steps.prepare.outputs.version }}" \
|
||||
--label "org.label-schema.vcs-ref=${GITHUB_SHA::8}" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \
|
||||
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \
|
||||
--file Dockerfile .
|
||||
-
|
||||
name: Docker Check Manifest
|
||||
if: always() && startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
|
||||
-
|
||||
name: Clear
|
||||
if: always() && startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
rm -f ${HOME}/.docker/config.json
|
66
.github/workflows/test.yml
vendored
Normal file
66
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: master
|
||||
push:
|
||||
branches: master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Prepare
|
||||
id: prepare
|
||||
run: |
|
||||
echo ::set-output name=build_tag::test
|
||||
echo ::set-output name=container_name::jetbrains-license-server
|
||||
echo ::set-output name=running_timeout::120
|
||||
echo ::set-output name=running_log_check::is listening on
|
||||
-
|
||||
# https://github.com/actions/checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
-
|
||||
# https://github.com/crazy-max/ghaction-docker-buildx
|
||||
name: Set up Docker Buildx
|
||||
uses: crazy-max/ghaction-docker-buildx@v1
|
||||
with:
|
||||
version: latest
|
||||
-
|
||||
name: Docker Buildx
|
||||
run: |
|
||||
docker buildx build --load --tag ${{ steps.prepare.outputs.build_tag }} --file Dockerfile .
|
||||
-
|
||||
name: Start container
|
||||
run: |
|
||||
docker rm -f ${{ steps.prepare.outputs.container_name }} > /dev/null 2>&1 || true
|
||||
docker run -d --name ${{ steps.prepare.outputs.container_name }} \
|
||||
-e "JLS_VIRTUAL_HOSTS=docker.test" \
|
||||
${{ steps.prepare.outputs.build_tag }}
|
||||
-
|
||||
name: Test run
|
||||
run: |
|
||||
TIMEOUT=$((SECONDS + ${{ steps.prepare.outputs.running_timeout }}))
|
||||
while read LOGLINE; do
|
||||
echo ${LOGLINE}
|
||||
if [[ ${LOGLINE} == *"${{ steps.prepare.outputs.running_log_check }}"* ]]; then
|
||||
echo "🎉 Container up!"
|
||||
break
|
||||
fi
|
||||
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
|
||||
>&2 echo "❌ Failed to run ${{ steps.prepare.outputs.container_name }} container"
|
||||
docker rm -f ${{ steps.prepare.outputs.container_name }} > /dev/null 2>&1 || true
|
||||
exit 1
|
||||
fi
|
||||
done < <(docker logs -f ${{ steps.prepare.outputs.container_name }} 2>&1)
|
||||
|
||||
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ steps.prepare.outputs.container_name }})
|
||||
if [[ ${CONTAINER_STATUS} != "running" ]]; then
|
||||
>&2 echo "❌ Container ${{ steps.prepare.outputs.container_name }} returned status '$CONTAINER_STATUS'"
|
||||
docker rm -f ${{ steps.prepare.outputs.container_name }} > /dev/null 2>&1 || true
|
||||
exit 1
|
||||
fi
|
||||
docker rm -f ${{ steps.prepare.outputs.container_name }} > /dev/null 2>&1 || true
|
||||
echo
|
29
.travis.yml
29
.travis.yml
@ -1,29 +0,0 @@
|
||||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
env:
|
||||
global:
|
||||
- VERSION=20308
|
||||
- DOCKER_LOGIN=crazymax
|
||||
- DOCKER_USERNAME=crazymax
|
||||
- DOCKER_REPONAME=jetbrains-license-server
|
||||
- QUAY_LOGIN=crazymax
|
||||
- QUAY_USERNAME=crazymax
|
||||
- QUAY_REPONAME=jetbrains-license-server
|
||||
- secure: JwfXiiIM4c6E+80O6XHQBhw6IdkerfGxlKo+YHvmtkHyz5Fvpc1ZRvWSZYHZhxE1gocThbKUCy4GsgIyiq+dsER27kdAnnvp6JLw8SZ5OSqtOOLjqCKilN2hwFaS/g6Xc3mGvTo+4ScAc9CDJamDCwGY+6r2g/+IdmCbgqOo8yaD4VkhP4eVB3f4el6F7jEwjo626QDzFZ1LVS0qmmeVBSU+xxfL5HolG+j//hLQ/49XIIGnsWtQmHbX1u2trSESyNRTFdY/KZ7qaW8l+BgLhplKu+YXAExb1POGcKJnffSJjCl22ggX1JUHANMgrcQfZe2DKkUJFqr8FvTCktj+lfAuMYwl3k24zcZHe8eTyBFh8YLs7pn++tOFWg0XcKCWO9vzHgbTf/m95F6tpDMx4Y49jRclJIslxkjf8YIuNvDOO4kPKp2bw4ymqjsayPLx3P4xB8vgvyAZeFBQevUkh3ia/3uCfwEwzWimlT1FTeDUj8h4A9y+zRy/AqGf35LneC/Sbwt5dNaCujAwOGFeCvTp43uYd10S5Rz026ecH/8XlcHzuH4+nUvXDnesRI79+6NkaKl8PdcTx0ZC44jIAULn60rur5ybNkQmv5GWjem1C24izosPuC8bLHYY6BSRPn+vacNZH9SYTw2wHiVunxZORWz4FsYAidFkoaygt9E= # DOCKER_PASSWORD
|
||||
- secure: Z+SIP2bLs70GcInLxGdYv68vXD47RIfowafFP8KpVt7EHki6AsIVJxrEH4/noj0jsx0Zyi93xAo+Z9Ms+BDsjUKeLjODS/mHjRQBrnryenjAnS8cRVvJUUDYcoY95SIOO4j6OSEIb+aI2d+6T2QX/iEgnEFDjiia2mLJ60orsWDtgoU7dgITB7ci4WkSMZl8VXtX7SUWKgVPRKkapfYX/AFUS41MZTnJvGQHCtTYlOMcS7fsf6ahjMvbTmf+otv2n688Mbg8Tz3cEw6YD5BHemfDq5qEJqjjnCtMIr5VSZttDwKwHsgmHrVEoiPq+Cdo+xwq3XCdfKu/qAD7NalBjNVaf6UjLjhkk4CWwLxQFnon1e8EC8GodXob4jQTGVOQX47lkPCvf6zM14GI1YxGMtofkv5ND7Ul/g+9fsn+b/QJFsuQb3ZA34pufjQQ5HRaj0ZU7izXIpUOu5EVo5ffrmUnrTisVNaSuIUonEt0p1WPFhdr1ScUc/VukF+wapDdSrSu/t8a5MXp0q3nZ+20NHlkm90o8umQqS8U1oo/n1hlEWTpC4PtRd4wggz0YNGTIKLpuxUt8HolU9rSPbGcbMLC53bNxnWd9KFaaFmRj5Np1GsBm2CDAPFYb3n/Dqyww+tg9Nk4MnCLMwROyZ+5Y7UQLtG5Tsh9tCtwPtT7Juk= # QUAY_PASSWORD
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- docker --version
|
||||
|
||||
script: ./build.sh
|
||||
|
||||
notifications:
|
||||
email:
|
||||
recipients:
|
||||
- travisci@crazymax.dev
|
||||
on_success: always
|
||||
on_failure: always
|
121
build.sh
121
build.sh
@ -1,121 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
PROJECT=jetbrains-license-server
|
||||
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
BUILD_TAG=docker_build
|
||||
BUILD_WORKINGDIR=${BUILD_WORKINGDIR:-.}
|
||||
DOCKERFILE=${DOCKERFILE:-Dockerfile}
|
||||
VCS_REF=${TRAVIS_COMMIT::7}
|
||||
RUNNING_TIMEOUT=120
|
||||
RUNNING_LOG_CHECK="is listening on"
|
||||
|
||||
PUSH_LATEST=${PUSH_LATEST:-true}
|
||||
DOCKER_USERNAME=${DOCKER_USERNAME:-crazymax}
|
||||
DOCKER_LOGIN=${DOCKER_LOGIN:-crazymax}
|
||||
DOCKER_REPONAME=${DOCKER_REPONAME:-jetbrains-license-server}
|
||||
QUAY_USERNAME=${QUAY_USERNAME:-crazymax}
|
||||
QUAY_LOGIN=${QUAY_LOGIN:-crazymax}
|
||||
QUAY_REPONAME=${QUAY_REPONAME:-jetbrains-license-server}
|
||||
|
||||
# Check local or travis
|
||||
BRANCH=${TRAVIS_BRANCH:-local}
|
||||
if [[ ${TRAVIS_PULL_REQUEST} == "true" ]]; then
|
||||
BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
|
||||
fi
|
||||
DOCKER_TAG=${BRANCH:-local}
|
||||
if [[ "$BRANCH" == "master" ]]; then
|
||||
DOCKER_TAG=latest
|
||||
elif [[ "$BRANCH" == "local" ]]; then
|
||||
BUILD_DATE=
|
||||
VERSION=local
|
||||
fi
|
||||
|
||||
echo "PROJECT=${PROJECT}"
|
||||
echo "VERSION=${VERSION}"
|
||||
echo "BUILD_DATE=${BUILD_DATE}"
|
||||
echo "BUILD_TAG=${BUILD_TAG}"
|
||||
echo "BUILD_WORKINGDIR=${BUILD_WORKINGDIR}"
|
||||
echo "DOCKERFILE=${DOCKERFILE}"
|
||||
echo "VCS_REF=${VCS_REF}"
|
||||
echo "PUSH_LATEST=${PUSH_LATEST}"
|
||||
echo "DOCKER_LOGIN=${DOCKER_LOGIN}"
|
||||
echo "DOCKER_USERNAME=${DOCKER_USERNAME}"
|
||||
echo "DOCKER_REPONAME=${DOCKER_REPONAME}"
|
||||
echo "QUAY_LOGIN=${QUAY_LOGIN}"
|
||||
echo "QUAY_USERNAME=${QUAY_USERNAME}"
|
||||
echo "QUAY_REPONAME=${QUAY_REPONAME}"
|
||||
echo "TRAVIS_BRANCH=${TRAVIS_BRANCH}"
|
||||
echo "TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}"
|
||||
echo "BRANCH=${BRANCH}"
|
||||
echo "DOCKER_TAG=${DOCKER_TAG}"
|
||||
echo
|
||||
|
||||
# Build
|
||||
echo "### Build"
|
||||
docker build \
|
||||
--build-arg BUILD_DATE=${BUILD_DATE} \
|
||||
--build-arg VCS_REF=${VCS_REF} \
|
||||
--build-arg VERSION=${VERSION} \
|
||||
-t ${BUILD_TAG} -f ${DOCKERFILE} ${BUILD_WORKINGDIR}
|
||||
echo
|
||||
|
||||
echo "### Test"
|
||||
docker rm -f ${PROJECT} > /dev/null 2>&1 || true
|
||||
docker run -d -p 8000:8000 \
|
||||
-e "JLS_VIRTUAL_HOSTS=docker.test" \
|
||||
--name ${PROJECT} ${BUILD_TAG}
|
||||
echo
|
||||
|
||||
echo "### Waiting for ${PROJECT} to be up..."
|
||||
TIMEOUT=$((SECONDS + RUNNING_TIMEOUT))
|
||||
while read LOGLINE; do
|
||||
echo ${LOGLINE}
|
||||
if [[ ${LOGLINE} == *"${RUNNING_LOG_CHECK}"* ]]; then
|
||||
echo "Container up!"
|
||||
break
|
||||
fi
|
||||
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
|
||||
>&2 echo "ERROR: Failed to run ${PROJECT} container"
|
||||
docker rm -f ${PROJECT} > /dev/null 2>&1 || true
|
||||
exit 1
|
||||
fi
|
||||
done < <(docker logs -f ${PROJECT} 2>&1)
|
||||
echo
|
||||
|
||||
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${PROJECT})
|
||||
if [[ ${CONTAINER_STATUS} != "running" ]]; then
|
||||
>&2 echo "ERROR: Container ${PROJECT} returned status '$CONTAINER_STATUS'"
|
||||
docker rm -f ${PROJECT} > /dev/null 2>&1 || true
|
||||
exit 1
|
||||
fi
|
||||
docker rm -f ${PROJECT} > /dev/null 2>&1 || true
|
||||
|
||||
if [ "${VERSION}" == "local" -o "${TRAVIS_PULL_REQUEST}" == "true" ]; then
|
||||
echo "INFO: This is a PR or a local build, skipping push..."
|
||||
exit 0
|
||||
fi
|
||||
if [[ ! -z ${DOCKER_PASSWORD} ]]; then
|
||||
echo "### Push to Docker Hub..."
|
||||
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_LOGIN" --password-stdin > /dev/null 2>&1
|
||||
if [ "${DOCKER_TAG}" == "latest" -a "${PUSH_LATEST}" == "true" ]; then
|
||||
docker tag ${BUILD_TAG} ${DOCKER_USERNAME}/${DOCKER_REPONAME}:${DOCKER_TAG}
|
||||
fi
|
||||
if [[ "${VERSION}" != "latest" ]]; then
|
||||
docker tag ${BUILD_TAG} ${DOCKER_USERNAME}/${DOCKER_REPONAME}:${VERSION}
|
||||
fi
|
||||
docker push ${DOCKER_USERNAME}/${DOCKER_REPONAME}
|
||||
echo
|
||||
fi
|
||||
if [[ ! -z ${QUAY_PASSWORD} ]]; then
|
||||
echo "### Push to Quay..."
|
||||
echo "$QUAY_PASSWORD" | docker login quay.io --username "$QUAY_LOGIN" --password-stdin > /dev/null 2>&1
|
||||
if [ "${DOCKER_TAG}" == "latest" -a "${PUSH_LATEST}" == "true" ]; then
|
||||
docker tag ${BUILD_TAG} quay.io/${QUAY_USERNAME}/${QUAY_REPONAME}:${DOCKER_TAG}
|
||||
fi
|
||||
if [[ "${VERSION}" != "latest" ]]; then
|
||||
docker tag ${BUILD_TAG} quay.io/${QUAY_USERNAME}/${QUAY_REPONAME}:${VERSION}
|
||||
fi
|
||||
docker push quay.io/${QUAY_USERNAME}/${QUAY_REPONAME}
|
||||
echo
|
||||
fi
|
Loading…
Reference in New Issue
Block a user