Update cicd.yaml #23
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: Continuous Integration and Continuous Deployment Suivie Physique | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build-test-deploy: | |
name: Build & Test & Deploy Suivie Physique App | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: 17 | |
- name: Cache Maven packages | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Unit Test Backend | |
run: mvn -B test --file backend/pom.xml | |
- name: Build Backend App | |
run: | | |
mvn clean | |
mvn -B package --file backend/pom.xml | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '16' | |
- name: Cache Node Modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: frontend/node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}-${{ runner.os }}-build-${{ runner.os }} | |
- name: Install Dependencies | |
run: | | |
npm install --prefix frontend | |
npm install --prefix frontend tailwindcss postcss autoprefixer | |
# - name: Running Frontend Tests | |
# run: npm run test:ci --prefix frontend | |
- name: Building Frontend App | |
run: npm run build:ci --prefix frontend | |
- name: Packaging App | |
run: mvn clean package | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Dockerhub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build to Dockerhub | |
run: docker-compose build | |
- name: Tag to Dockerhub | |
run: | | |
docker tag backend:latest dotcipher/sp-backend:latest | |
docker tag frontend:latest dotcipher/sp-frontend:latest | |
- name: Push to Dockerhub | |
run: | | |
docker push dotcipher/sp-backend:latest | |
docker push dotcipher/sp-frontend:latest |