Merge pull request #91 from anct-cnum/recette #27
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: Déploiement sur l'espace de production | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
jobs: | |
dependencies: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.9.0] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Retrieve cached dependencies | |
id: retrieve-dependencies | |
uses: actions/cache@v3 | |
with: | |
key: node_modules-${{ hashFiles('package-lock.json') }} | |
path: node_modules | |
- name: Install dependencies | |
if: steps.retrieve-dependencies.outputs.cache-hit == false | |
run: npm ci --omit=dev | |
- name: Cache dependencies if not present | |
if: steps.retrieve-dependencies.outputs.cache-hit == false | |
uses: actions/cache@v3 | |
with: | |
key: node_modules.-${{ hashFiles('package-lock.json') }} | |
path: node_modules | |
build: | |
needs: dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Retrieve cached dependencies | |
uses: actions/cache@v3 | |
with: | |
key: node_modules-${{ hashFiles('package-lock.json') }} | |
path: node_modules | |
- name: Override .env | |
uses: SpicyPizza/[email protected] | |
with: | |
envkey_REACT_APP_STRATEGYAUTH: "local" | |
envkey_REACT_APP_VERSION: "1.0" | |
envkey_REACT_APP_API: ${{ secrets.REACT_APP_API_PRODUCTION }} | |
envkey_REACT_APP_CV_FILE_MAX_SIZE: 10485760 | |
envkey_REACT_APP_PIX_CAMPAGNE_URL: ${{ secrets.REACT_APP_PIX_CAMPAGNE_URL }} | |
envkey_REACT_APP_PIX_URL: "https://app.pix.fr/connexion" | |
file_name: .env | |
- name: Build application | |
run: npm run build | |
- name: copy .htaccess | |
uses: canastro/copy-file-action@master | |
with: | |
source: ".htaccess" | |
target: "build/.htaccess" | |
- name: Upload release bundle as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bundle | |
path: build/* | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Retrieve bundle React | |
uses: actions/download-artifact@v3 | |
with: | |
name: bundle | |
path: build | |
- name: Deploy on clever cloud | |
uses: s0/git-publish-subdir-action@develop | |
env: | |
REPO: ${{ secrets.CLEVER_CLOUD_GIT_PORTAIL_CANDIDAT_PRODUCTION }} | |
BRANCH: master | |
FOLDER: build | |
SSH_PRIVATE_KEY: ${{ secrets.CLEVER_CLOUD_DEPLOY_PRIVATE_KEY }} | |
KNOWN_HOSTS_FILE: resources/known_hosts |