moved from circle ci to github actions

Signed-off-by: André Bauer <monotek23@gmail.com>
This commit is contained in:
André Bauer 2020-03-04 21:23:02 +01:00
parent e61fa6795e
commit 0798e7d47e
8 changed files with 108 additions and 113 deletions

View file

@ -1,67 +0,0 @@
version: 2.1
jobs:
lint-scripts:
docker:
- image: koalaman/shellcheck-alpine
steps:
- checkout
- run:
name: lint-scripts
command: .circleci/lint-scripts.sh
install-mysql:
docker:
- image: circleci/ruby:2.5.5
- image: circleci/mysql:5.7-ram
command: --max_allowed_packet=64MB
environment:
MYSQL_DATABASE: zammad_test
MYSQL_USER: zammad_test
MYSQL_PASSWORD: zammad_test
environment:
RAILS_ENV: test
steps:
- checkout
- run:
name: install-mysql
command: .circleci/install.sh
install-postgresql:
docker:
- image: circleci/ruby:2.5.5
- image: circleci/postgres:11-ram
environment:
POSTGRES_DB: zammad_test
POSTGRES_USER: zammad_test
POSTGRES_PASSWORD: zammad_test
environment:
RAILS_ENV: test
steps:
- checkout
- run:
name: install-postgresql
command: .circleci/install.sh
docker-image-build:
machine: true
steps:
- checkout
- run:
name: docker-image-build
command: .circleci/docker-image-build.sh
workflows:
version: 2
install_unittest_dockerbuild:
jobs:
- lint-scripts
- install-mysql:
requires:
- lint-scripts
- install-postgresql:
requires:
- lint-scripts
- docker-image-build:
requires:
- install-mysql
- install-postgresql

View file

@ -1,39 +0,0 @@
#!/usr/bin/env bash
#
# build zammads docker & docker-compose images
set -o errexit
set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
GITHUB_REPO_USER="zammad"
ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')"
export ZAMMAD_VERSION
if [ "${CIRCLE_BRANCH}" == 'develop' ]; then
BUILD_SCRIPT="scripts/build_image.sh"
DOCKER_REPOSITORY="zammad"
export DOCKER_REPOSITORY
GITHUB_REPOSITORY="zammad-docker"
elif [ "${CIRCLE_BRANCH}" == 'stable' ]; then
BUILD_SCRIPT="hooks/build"
DOCKER_REPOSITORY="zammad-docker-compose"
export DOCKER_REPOSITORY
GITHUB_REPOSITORY="zammad-docker-compose"
else
echo "branch is ${CIRCLE_BRANCH}... no docker image build needed..."
exit 0
fi
# dockerhub auth
echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin
# clone docker repo
git clone https://github.com/"${GITHUB_REPO_USER}"/"${GITHUB_REPOSITORY}"
# enter dockerfile dir
cd "${REPO_ROOT}/${GITHUB_REPOSITORY}"
# build & push docker image
# shellcheck disable=SC1090
source "${REPO_ROOT}/${GITHUB_REPOSITORY}/${BUILD_SCRIPT}"

View file

@ -12,15 +12,12 @@ DB_CONFIG="test:\n adapter: postgresql\n database: zammad_test\n host: 127.0.
sudo apt-get update sudo apt-get update
sudo apt-get install -y --no-install-recommends autoconf automake autotools-dev bison build-essential curl git-core libffi-dev libgdbm-dev libgmp-dev libmariadbclient-dev-compat libncurses5-dev libreadline-dev libsqlite3-dev libssl-dev libtool libxml2-dev libxslt1-dev libyaml-0-2 libyaml-dev patch pkg-config postfix sqlite3 zlib1g-dev libimlib2 libimlib2-dev sudo apt-get install -y --no-install-recommends autoconf automake autotools-dev bison build-essential curl git-core libffi-dev libgdbm-dev libgmp-dev libmariadbclient-dev-compat libncurses5-dev libreadline-dev libsqlite3-dev libssl-dev libtool libxml2-dev libxslt1-dev libyaml-0-2 libyaml-dev patch pkg-config postfix sqlite3 zlib1g-dev libimlib2 libimlib2-dev
if [ "${CIRCLE_JOB}" == "install-mysql" ]; then if [ "${ZAMMAD_DBS}" == "mysql" ]; then
DB_ADAPTER="mysql2" DB_ADAPTER="mysql2"
INSTALL_OPTION="postgres" INSTALL_OPTION="postgres"
elif [ "${CIRCLE_JOB}" == "install-postgresql" ]; then elif [ "${ZAMMAD_DBS}" == "postgresql" ]; then
DB_ADAPTER="postgresql" DB_ADAPTER="postgresql"
INSTALL_OPTION="mysql" INSTALL_OPTION="mysql"
else
echo "nothing to do for circle ci job ${CIRCLE_JOB}..."
exit 0
fi fi
# create db config # create db config

33
.github/docker-image-build.sh vendored Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
#
# build zammads docker & docker-compose images
set -o errexit
set -o pipefail
DOCKER_REGISTRY="index.docker.io"
REPO_ROOT="$(git rev-parse --show-toplevel)"
REPO_USER="zammad"
ZAMMAD_VERSION="$(git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g')"
# dockerhub auth
echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin
# clone docker repo
git clone https://github.com/"${REPO_USER}"/"${GITHUB_REPOSITORY}"
# enter dockerfile dir
cd "${REPO_ROOT}/${GITHUB_REPOSITORY}"
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
echo "Build Zammad Docker image ${DOCKER_IMAGE} with version ${ZAMMAD_VERSION} for DockerHubs ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE} repo"
if [ "${DOCKER_REPOSITORY}" == "zammad-docker-compose" ]; then
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE} -t ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-latest -t ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${ZAMMAD_VERSION} -f containers/${DOCKER_IMAGE}/Dockerfile .
docker push ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-latest
else
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +”%Y-%m-%dT%H:%M:%SZ”)" -t ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:latest -t ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${ZAMMAD_VERSION} .
fi
docker push ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}
docker push ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${ZAMMAD_VERSION}
fi

View file

@ -5,7 +5,8 @@
set -o errexit set -o errexit
CONFIG_DIR="./.circleci" CONFIG_DIR=".github"
TMP_FILE="$(mktemp)" TMP_FILE="$(mktemp)"
find "${CONFIG_DIR}" -type f -name "*.sh" > "${TMP_FILE}" find "${CONFIG_DIR}" -type f -name "*.sh" > "${TMP_FILE}"
@ -15,4 +16,3 @@ while read -r FILE; do
shellcheck -x "${FILE}" shellcheck -x "${FILE}"
done < "${TMP_FILE}" done < "${TMP_FILE}"
rm "${TMP_FILE}"

View file

@ -0,0 +1,20 @@
name: build-docker-compose-images
on:
push:
branches: [stable]
jobs:
build-docker-compose-images:
runs-on: ubuntu-latest
env:
DOCKER_IMAGES: "zammad zammad-elasticsearch zammad-postgresql"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: "zammad-docker-compose"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
GITHUB_REPOSITORY: "zammad-docker-compose"
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Build docker image
run: .github/docker-image-build.sh

View file

@ -0,0 +1,20 @@
name: build-docker-image
on:
push:
branches: [develop]
jobs:
build-docker-image:
runs-on: ubuntu-latest
env:
DOCKER_IMAGES: "zammad"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REPOSITORY: "zammad"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
GITHUB_REPOSITORY: "zammad-docker"
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Build docker image
run: .github/docker-image-build.sh

31
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,31 @@
name: ci
on:
pull_request:
jobs:
lint-bash-scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Lint Bash scripts
uses: docker://koalaman/shellcheck-alpine:v0.7.0
with:
args: .github/lint-scripts.sh
ci:
runs-on: ubuntu-latest
needs: lint-scripts
strategy:
matrix:
dbs:
- mysql
- postgresql
env:
ZAMMAD_DBS: ${{ matrix.dbs }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: CI
run: .github/ci.sh