From 1d55cf5605be9f92110cb279e26adef354523773 Mon Sep 17 00:00:00 2001 From: Breval Date: Tue, 27 Aug 2024 15:56:20 +0200 Subject: [PATCH] fix: elegage massive de la ci desactiovation de la preprod, test de build only --- .github/workflows/build-test.yml | 174 +++++++++++------------ .github/workflows/deploy-preprod.yml | 52 ------- .github/workflows/deploy-preprod.yml.old | 52 +++++++ .github/workflows/deploy-prod.yml | 9 +- 4 files changed, 145 insertions(+), 142 deletions(-) delete mode 100644 .github/workflows/deploy-preprod.yml create mode 100644 .github/workflows/deploy-preprod.yml.old diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9b7d3ba2..9b71dcc9 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -58,90 +58,90 @@ jobs: NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} NEXT_PUBLIC_URL=${{ vars.NEXT_PUBLIC_URL }} - tests: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # Run copies of the current job in parallel. These need to be a - # continuous series of numbers, starting with `0`. If you change the - # number of containers, change TOTAL_RUNNERS below. - containers: [ 0, 1, 2, 3 ] - needs: build - steps: - - uses: actions/checkout@v4 - - name: Cache next.js build - id: cache-npm - uses: actions/cache@v4 - with: - path: .next/ - key: ${{ runner.os }}-next-build-${{ hashFiles('src/','public/','next*','package*','jsconfig.json') }} - - name: List files - run: ls -la - - name: Add container env vars - run: echo "THIS_RUNNER=${{ matrix.containers }}" >> $GITHUB_ENV - - name: Cypress run - uses: cypress-io/github-action@v5 - with: - start: npm run start - browser: chrome - wait-on: 'http://localhost:3000' - command: yarn node cypress/cypress-ci-run.mjs - record: true - env: ENV=production - NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} - NEXT_PUBLIC_URL=${{ vars.NEXT_PUBLIC_URL }} - NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} - NEXT_PUBLIC_DATABASE_URL=${{ secrets.NEXT_PUBLIC_DATABASE_URL }} - NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} - GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} - GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} - FACEBOOK_CLIENT_ID=${{ secrets.FACEBOOK_CLIENT_ID }} - FACEBOOK_CLIENT_SECRET=${{ secrets.FACEBOOK_CLIENT_SECRET }} - MAILGUN_API_KEY=${{ secrets.MAILGUN_API_KEY }} - MAILGUN_API_URL=${{ secrets.MAILGUN_API_URL }} - MAILGUN_PUBLIC_KEY=${{ secrets.MAILGUN_PUBLIC_KEY }} - MAILGUN_DOMAIN=${{ secrets.MAILGUN_DOMAIN }} - CYPRESS_TEST_USER=${{ secrets.TEST_USER }} - CYPRESS_TEST_PW=${{ secrets.TEST_PW }} - CYPRESS_NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} - CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }} - CYPRESS_RETRIES=3 - GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - - uses: actions/upload-artifact@v4 - # add the line below to store screenshots only on failures - if: failure() - with: - name: cypress-screenshots - path: cypress/screenshots - if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` - - uses: actions/upload-artifact@v4 - # add the line below to store screenshots only on failures - if: failure() - with: - name: cypress-videos - path: cypress/videos - if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` - SonarQube: - environment: testing - runs-on: ubuntu-latest - needs: tests - steps: - - uses: actions/checkout@v4 - - uses: sonarsource/sonarqube-scan-action@master - with: - projectBaseDir: ./ - args: > - -Dsonar.python.coverage.reportPaths=coverage.xml - -Dproject.settings=./sonar-project.properties - -Dsonar.verbose=true - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - # If you wish to fail your job when the Quality Gate is red use the - # following lines. This would typically be used to fail a deployment. - - uses: sonarsource/sonarqube-quality-gate-action@master - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# tests: +# runs-on: ubuntu-latest +# strategy: +# fail-fast: false +# matrix: +# # Run copies of the current job in parallel. These need to be a +# # continuous series of numbers, starting with `0`. If you change the +# # number of containers, change TOTAL_RUNNERS below. +# containers: [ 0, 1, 2, 3 ] +# needs: build +# steps: +# - uses: actions/checkout@v4 +# - name: Cache next.js build +# id: cache-npm +# uses: actions/cache@v4 +# with: +# path: .next/ +# key: ${{ runner.os }}-next-build-${{ hashFiles('src/','public/','next*','package*','jsconfig.json') }} +# - name: List files +# run: ls -la +# - name: Add container env vars +# run: echo "THIS_RUNNER=${{ matrix.containers }}" >> $GITHUB_ENV +# - name: Cypress run +# uses: cypress-io/github-action@v5 +# with: +# start: npm run start +# browser: chrome +# wait-on: 'http://localhost:3000' +# command: yarn node cypress/cypress-ci-run.mjs +# record: true +# env: ENV=production +# NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} +# NEXT_PUBLIC_URL=${{ vars.NEXT_PUBLIC_URL }} +# NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} +# NEXT_PUBLIC_DATABASE_URL=${{ secrets.NEXT_PUBLIC_DATABASE_URL }} +# NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} +# GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }} +# GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }} +# FACEBOOK_CLIENT_ID=${{ secrets.FACEBOOK_CLIENT_ID }} +# FACEBOOK_CLIENT_SECRET=${{ secrets.FACEBOOK_CLIENT_SECRET }} +# MAILGUN_API_KEY=${{ secrets.MAILGUN_API_KEY }} +# MAILGUN_API_URL=${{ secrets.MAILGUN_API_URL }} +# MAILGUN_PUBLIC_KEY=${{ secrets.MAILGUN_PUBLIC_KEY }} +# MAILGUN_DOMAIN=${{ secrets.MAILGUN_DOMAIN }} +# CYPRESS_TEST_USER=${{ secrets.TEST_USER }} +# CYPRESS_TEST_PW=${{ secrets.TEST_PW }} +# CYPRESS_NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} +# CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }} +# CYPRESS_RETRIES=3 +# GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} +# - uses: actions/upload-artifact@v4 +# # add the line below to store screenshots only on failures +# if: failure() +# with: +# name: cypress-screenshots +# path: cypress/screenshots +# if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` +# - uses: actions/upload-artifact@v4 +# # add the line below to store screenshots only on failures +# if: failure() +# with: +# name: cypress-videos +# path: cypress/videos +# if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` +# SonarQube: +# environment: testing +# runs-on: ubuntu-latest +# needs: tests +# steps: +# - uses: actions/checkout@v4 +# - uses: sonarsource/sonarqube-scan-action@master +# with: +# projectBaseDir: ./ +# args: > +# -Dsonar.python.coverage.reportPaths=coverage.xml +# -Dproject.settings=./sonar-project.properties +# -Dsonar.verbose=true +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} +# +# # If you wish to fail your job when the Quality Gate is red use the +# # following lines. This would typically be used to fail a deployment. +# - uses: sonarsource/sonarqube-quality-gate-action@master +# timeout-minutes: 5 +# env: +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/deploy-preprod.yml b/.github/workflows/deploy-preprod.yml deleted file mode 100644 index ddd1510f..00000000 --- a/.github/workflows/deploy-preprod.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build and Deploy on preprod - -env: - NEXT_PUBLIC_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }} - NEXT_PUBLIC_URL: ${{ vars.NEXT_PUBLIC_URL }} - -on: - push: - branches: [main] - -jobs: - build-and-push: - runs-on: ubuntu-latest - environment: pre-prod - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Use Node.js 20.x - uses: actions/setup-node@v4 - with: - cache: 'npm' - node-version: 20.x - - name: Install dependencies in production - run: npm ci --ignore-scripts - - name: Cache next.js build - id: cache-npm - uses: actions/cache@v4 - with: - path: .next/ - key: ${{ runner.os }}-next-build-${{ hashFiles('src/','public/','next*','package*','jsconfig.json') }} - - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} - name: Build the app - continue-on-error: true - run: npm run build - - name: List files - run: ls -la - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ secrets.APP_IMAGE }} - build-args: - NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} - NEXT_PUBLIC_URL=${{ vars.NEXT_PUBLIC_URL }} - - name: Deploy on cap rover - run: docker run caprover/cli-caprover:latest caprover deploy --caproverUrl "${{ secrets.APP_URL }}" --appToken "${{ secrets.APP_TOKEN }}" --caproverApp "${{ secrets.APP_NAME }}" --imageName "${{ secrets.APP_IMAGE }}" diff --git a/.github/workflows/deploy-preprod.yml.old b/.github/workflows/deploy-preprod.yml.old new file mode 100644 index 00000000..53d05a11 --- /dev/null +++ b/.github/workflows/deploy-preprod.yml.old @@ -0,0 +1,52 @@ +#name: Build and Deploy on preprod +# +#env: +# NEXT_PUBLIC_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }} +# NEXT_PUBLIC_URL: ${{ vars.NEXT_PUBLIC_URL }} +# +#on: +# push: +# branches: [main] +# +#jobs: +# build-and-push: +# runs-on: ubuntu-latest +# environment: pre-prod +# steps: +# - name: Checkout code +# uses: actions/checkout@v4 +# - name: Use Node.js 20.x +# uses: actions/setup-node@v4 +# with: +# cache: 'npm' +# node-version: 20.x +# - name: Install dependencies in production +# run: npm ci --ignore-scripts +# - name: Cache next.js build +# id: cache-npm +# uses: actions/cache@v4 +# with: +# path: .next/ +# key: ${{ runner.os }}-next-build-${{ hashFiles('src/','public/','next*','package*','jsconfig.json') }} +# - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} +# name: Build the app +# continue-on-error: true +# run: npm run build +# - name: List files +# run: ls -la +# - name: Login to Docker Hub +# uses: docker/login-action@v3 +# with: +# username: ${{ secrets.DOCKER_USERNAME }} +# password: ${{ secrets.DOCKER_PASSWORD }} +# - name: Build and push Docker image +# uses: docker/build-push-action@v5 +# with: +# context: . +# push: true +# tags: ${{ secrets.APP_IMAGE }} +# build-args: +# NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} +# NEXT_PUBLIC_URL=${{ vars.NEXT_PUBLIC_URL }} +# - name: Deploy on cap rover +# run: docker run caprover/cli-caprover:latest caprover deploy --caproverUrl "${{ secrets.APP_URL }}" --appToken "${{ secrets.APP_TOKEN }}" --caproverApp "${{ secrets.APP_NAME }}" --imageName "${{ secrets.APP_IMAGE }}" diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 4871d71a..4f06f915 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -1,13 +1,15 @@ name: Build and Deploy on prod + env: NEXT_PUBLIC_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }} NEXT_PUBLIC_URL: ${{ vars.NEXT_PUBLIC_URL }} + on: push: tags: - - v* + - 'v*.*.*' jobs: build-and-push: @@ -49,5 +51,6 @@ jobs: build-args: NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }} NEXT_PUBLIC_URL=${{ vars.NEXT_PUBLIC_URL }} - - name: Deploy on cap rover - run: docker run caprover/cli-caprover:latest caprover deploy --caproverUrl "${{ secrets.APP_URL }}" --appToken "${{ secrets.APP_TOKEN }}" --caproverApp "${{ secrets.APP_NAME }}" --imageName "${{ secrets.APP_IMAGE }}" + - name: Deploy to Coolify + run: | + curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'