Skip to content

Commit

Permalink
Merge pull request #109 from bart2001/feature/github-action
Browse files Browse the repository at this point in the history
[CI/CD] add github action file for building and publishing docker image
  • Loading branch information
ralfyang authored Sep 13, 2021
2 parents cde2205 + a4b46cc commit bd66f0b
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 bd66f0b

Please sign in to comment.