build-and-push-docker-image #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-push-docker-image | |
on: | |
workflow_run: | |
workflows: "test-backend" | |
branches: main | |
types: completed | |
jobs: | |
# define job to build and publish docker image | |
build-and-push-docker-image: | |
runs-on: ubuntu-22.04 | |
# run only when code is compiling and tests are passing | |
if: github.event.workflow_run.conclusion == 'success' | |
# steps to perform in job | |
steps: | |
#checkout your github code using actions/[email protected] | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Login to DockerHub | |
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_AUTH }} | |
- name: Build image and push backend | |
uses: docker/[email protected] | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: TP01/simple-api-student-main | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/tp01-api:1.0 | |
# build on feature branches, push only on main branch | |
push: ${{ github.ref == 'refs/heads/main' }} | |
- name: Build image and push database | |
uses: docker/[email protected] | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: TP01/db | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/tp01-postgres:1.0 | |
# build on feature branches, push only on main branch | |
push: ${{ github.ref == 'refs/heads/main' }} | |
- name: Build image and push http | |
uses: docker/[email protected] | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: TP01/web | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/tp01-web:1.0 | |
# build on feature branches, push only on main branch | |
push: ${{ github.ref == 'refs/heads/main' }} | |
- name: Build image and push frontend | |
uses: docker/[email protected] | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: TP03/devops-front-main | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/tp03-frontend:1.0 | |
# build on feature branches, push only on main branch | |
push: ${{ github.ref == 'refs/heads/main' }} |