Skip to content

Commit

Permalink
add github action file for build and publish docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
bart2001 committed Sep 6, 2021
1 parent 26e9e34 commit a4b46cc
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and Publish Docker Container
on:
push:
tags: [ 'fe*.*.*', 'api*.*.*' ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build & Push Docker Image (FrontEnd)
if : ${{ startsWith(steps.tag.outputs.tag, 'fe') }}
run: |
docker build -t ${{ secrets.DOCKERHUB_FRONTEND_REPO }}:release-${{ steps.tag.outputs.tag }} ./ --no-cache
docker tag ${{ secrets.DOCKERHUB_FRONTEND_REPO }}:release-${{ steps.tag.outputs.tag }} ${{ secrets.DOCKERHUB_FRONTEND_REPO }}:latest
docker push ${{ secrets.DOCKERHUB_FRONTEND_REPO }}:release-${{ steps.tag.outputs.tag }}
docker push ${{ secrets.DOCKERHUB_FRONTEND_REPO }}:latest
- name: Build & Push Docker Image (BackEnd)
if : ${{ startsWith(steps.tag.outputs.tag, 'api') }}
run: |
cd api
docker build -t ${{ secrets.DOCKERHUB_BACKEND_REPO }}:release-${{ steps.tag.outputs.tag }} ./ --no-cache
docker tag ${{ secrets.DOCKERHUB_BACKEND_REPO }}:release-${{ steps.tag.outputs.tag }} ${{ secrets.DOCKERHUB_BACKEND_REPO }}:latest
docker push ${{ secrets.DOCKERHUB_BACKEND_REPO }}:release-${{ steps.tag.outputs.tag }}
docker push ${{ secrets.DOCKERHUB_BACKEND_REPO }}:latest

0 comments on commit a4b46cc

Please sign in to comment.