Skip to content

Commit

Permalink
Create docker-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
danparisd authored Nov 9, 2023
1 parent 61ac1bb commit 204a726
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- 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

0 comments on commit 204a726

Please sign in to comment.