From 204a7264ae38bfb96306c895eee29deb8192c79e Mon Sep 17 00:00:00 2001 From: danparisd <43418833+danparisd@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:25:35 -0500 Subject: [PATCH] Create docker-build.yml --- .github/workflows/docker-build.yml | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..8fa2b58 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,60 @@ +name: Build wacs Docker Image + +on: + push: + paths: + - 'wacs-gitea/**' + - '.github/workflows/docker-build.yml' + pull_request: + workflow_dispatch: + +jobs: + #build and publish image + Build-Image: + name: Build image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + + - name: Build image with buildx + uses: docker/build-push-action@v3 + with: + context: ./wacs-gitea + cache-from: type=gha + cache-to: type=gha,mode=max + + Push-Image: + name: Push images if this is a branch + runs-on: ubuntu-latest + needs: [Build-Image] + if: ${{ contains(fromJson('["push"]'), github.event_name) }} + steps: + - uses: actions/checkout@v3 + - uses: FranzDiebold/github-env-vars-action@v2.7.0 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Set docker tags + run: | + echo "TAG_SHA=wycliffeassociates/wacs:$GITHUB_SHA" >> $GITHUB_ENV && \ + echo "TAG_BRANCH=wycliffeassociates/wacs:$CI_REF_NAME_SLUG" >> $GITHUB_ENV && \ + echo "TAG_LATEST=wycliffeassociates/wacs:latest" >> $GITHUB_ENV + + - name: Build and conditional push API image + uses: docker/build-push-action@v3 + with: + context: ./wacs-gitea + push: true + tags: | + ${{ env.TAG_SHA }} + ${{ env.TAG_BRANCH }} + ${{ env.TAG_LATEST }} + cache-from: type=gha + cache-to: type=gha,mode=max +