ci: ajout push images #3
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: CI devops 2023 | |
on: | |
#to begin you want to launch this job in main and develop | |
push: | |
branches: #TODO | |
pull_request: | |
jobs: | |
test-backend: | |
runs-on: ubuntu-22.04 | |
steps: | |
#checkout your github code using actions/[email protected] | |
- uses: actions/[email protected] | |
#do the same with another action (actions/setup-java@v3) that enable to setup jdk 17 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" # See 'Supported distributions' for available options | |
java-version: "21" | |
#finally build your app with the latest command | |
- name: Build and test with Maven | |
run: cd backend-api && mvn clean verify | |
# define job to build and publish docker image | |
build-and-push-docker-image: | |
needs: test-backend | |
# 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/[email protected] | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- 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 | |
file: ./Dockerfile.api | |
push: true | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/api:latest | |
- 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 | |
file: ./Dockerfile.db | |
push: true | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/database:latest | |
- 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 | |
file: ./Dockerfile.http | |
push: true | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/httpd:latest |