diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..5faa5ab6 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 \ No newline at end of file