Skip to content

Build and Push Docker Image CI #26

Build and Push Docker Image CI

Build and Push Docker Image CI #26

name: Build and Push Docker Image CI
on:
workflow_run:
workflows: ["test-backend"]
types:
- completed
branches:
- main
jobs:
build-and-push-docker-image:
runs-on: ubuntu-22.04
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Login to DockerHub
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build image and push backend
uses: docker/build-push-action@v3
with:
context: simpleapi-student/simple-api-student-main/
tags: ${{ secrets.DOCKER_USER }}/api:1.0
push: ${{ github.ref == 'refs/heads/main' }}
- name: Build image and push database
uses: docker/build-push-action@v3
with:
context: docker/
tags: ${{ secrets.DOCKER_USER }}/postgres:1.0
push: ${{ github.ref == 'refs/heads/main' }}
- name: Build image and push httpd
uses: docker/build-push-action@v3
with:
context: html/
tags: ${{ secrets.DOCKER_USER }}/backend:1.0
push: ${{ github.ref == 'refs/heads/main' }}
- name: Build image and push front
uses: docker/build-push-action@v3
with:
context: devops-front-main/
tags: ${{ secrets.DOCKER_USER }}/front:1.0
push: ${{ github.ref == 'refs/heads/main' }}