From 5582368a8162534f7fa200ae61087defd82309b2 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 5 Apr 2022 16:00:10 +0200 Subject: [PATCH] Add a workflow for CI The workflow try to build the docker image on PR, and push a image on each commit, and stable version when there is a release Signed-off-by: Michael Scherer Ignore the frontend for now --- .github/workflows/build_docker.yml | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/build_docker.yml diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 0000000000..6254922afb --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,48 @@ +name: Build Docker images +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: + - published + +jobs: + build: + name: Build image + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v2 + - name: Run the build + run: | + set -ex + # use that here since the variable are not present before start, so can't be in env + export LOGIN=$GITHUB_REPOSITORY_OWNER + + echo $PASSWORD | docker login $REGISTRY -u $LOGIN --password-stdin + + for i in util/docker/* ; do + CONTAINER=$(basename $i) + if [[ $CONTAINER != 'frontend' ]]; then + echo "Building $CONTAINER" + export IMAGE=$LOGIN/augur_$CONTAINER + DOCKERFILE=${i}/Dockerfile + TAG=$GITHUB_SHA + + docker build . -f $DOCKERFILE --tag $REGISTRY/$IMAGE:$TAG --tag $REGISTRY/$IMAGE:latest + if [[ $GITHUB_EVENT_NAME == 'release' ]]; then + TAG=$(basename $GITHUB_REF) + docker push $REGISTRY/$IMAGE:latest + docker push $REGISTRY/$IMAGE:$TAG + elif [[ $GITHUB_EVENT_NAME == 'push' ]]; then + docker push $REGISTRY/$IMAGE-devel:latest + fi + fi + done + env: + REGISTRY: ghcr.io + PASSWORD: ${{ secrets.GITHUB_TOKEN }}