Switch to GitHub Actions
Stop publishing Docker image on Quay
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user