CD devops 2024 #5
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: CD devops 2024 | |
on: | |
#to begin to launch this job in main and develop | |
workflow_run: | |
workflows: [ "CI devops 2024" ] | |
types: | |
- completed | |
branches: | |
- main | |
jobs: | |
# define job to build and publish docker image | |
build-and-push-docker-image: | |
# run only when code is compiling and tests are passing | |
runs-on: ubuntu-22.04 | |
# steps to perform in job | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2.5.0 | |
# Login to Docker Hub | |
- name: Login to DockerHub | |
run: docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} | |
# shell: bash | |
- name: Build image and push backend | |
uses: docker/build-push-action@v3 | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: ./API/simpleapi | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKER_HUB_USERNAME}}/devops-app-simple-api:latest | |
push: ${{ github.ref == 'refs/heads/main' }} | |
- name: Build image and push database | |
uses: docker/build-push-action@v3 | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: ./postgres | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKER_HUB_USERNAME}}/devops-app-database:latest | |
push: ${{ github.ref == 'refs/heads/main' }} | |
- name: Build image and push httpd | |
uses: docker/build-push-action@v3 | |
with: | |
# relative path to the place where source code with Dockerfile is located | |
context: ./http-server | |
# Note: tags has to be all lower-case | |
tags: ${{secrets.DOCKER_HUB_USERNAME}}/devops-app-httpd:latest | |
push: ${{ github.ref == 'refs/heads/main' }} |