diff --git a/.github/workflows/deploy-to-scalingo-review-app.yml b/.github/workflows/deploy-to-scalingo-review-app.yml new file mode 100644 index 0000000000..bcbdcc7c32 --- /dev/null +++ b/.github/workflows/deploy-to-scalingo-review-app.yml @@ -0,0 +1,45 @@ +name: "Generic workflow to deploy to scalingo, given arguments" + +on: + workflow_call: + inputs: + pull_request_id: + type: number + required: true + secrets: + SCALINGO_API_TOKEN: + required: true + +jobs: + deploy: + name: "Deploy to review app pr${{ inputs.pull_request_id }}" + runs-on: ubuntu-latest + concurrency: + group: deploy-to-scalingo-pr${{ inputs.pull_request_id }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "pnpm" + - name: Install scalingo CLI + run: | + wget -qO- https://cli-dl.scalingo.com/install.sh | bash + echo "$HOME/bin" >> $GITHUB_PATH + - name: Install dependencies + run: pnpm install + - name: Build front + run: NODE_OPTIONS=--max-old-space-size=4096 pnpm front build-scalingo + - name: Build back + run: pnpm back build + - name: Login to scalingo + run: scalingo login --api-token ${{ secrets.SCALINGO_API_TOKEN }} + - name: Deploy back + run: scalingo --app if-dev-back-pr${{ inputs.pull_request_id }} deploy back/back-build.tar.gz pr${{ inputs.pull_request_id }} + - name: Deploy front + run: scalingo --app if-dev-front-pr${{ inputs.pull_request_id }} deploy front/front-build.tar.gz pr${{ inputs.pull_request_id }} diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml new file mode 100644 index 0000000000..9dec9f3cf6 --- /dev/null +++ b/.github/workflows/feature-branch.yml @@ -0,0 +1,22 @@ +name: "Continuous Deployment" + +on: + pull_request: + +jobs: + get-pr-number: + runs-on: ubuntu-latest + steps: + - name: Get PR Number + run: echo "PR Number is ${{ github.event.number }}" + + validation: + uses: ./.github/workflows/fullcheck.yml + + deploy-feature-branch: + uses: ./.github/workflows/deploy-to-scalingo-review-app.yml + needs: validation + with: + pull_request_id: ${{ github.event.number }} + secrets: + SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/fullcheck.yml b/.github/workflows/fullcheck.yml index 8afcfcfb9d..2535b7992f 100644 --- a/.github/workflows/fullcheck.yml +++ b/.github/workflows/fullcheck.yml @@ -1,10 +1,6 @@ name: "Fullcheck of the project + integration tests" on: - push: - branches-ignore: - - main - workflow_call: jobs: diff --git a/back/transpile-back-and-prepare-for-prod.js b/back/transpile-back-and-prepare-for-prod.js index 68583911d7..753f3c0a4e 100644 --- a/back/transpile-back-and-prepare-for-prod.js +++ b/back/transpile-back-and-prepare-for-prod.js @@ -26,12 +26,15 @@ console.log("Copying package.json of back for prod"); fs.copyFileSync("./package.json", "build/back/package.json"); execSync( - "cp -v -R ./src/adapters/secondary/pg/staticData build/back/src/adapters/secondary/pg/staticData" + "cp -v -R ./src/adapters/secondary/pg/staticData build/back/src/adapters/secondary/pg", ); // Copy dependencies package.json files to build directory fs.copyFileSync("../shared/package.json", "build/shared/package.json"); -fs.copyFileSync( "../libs/html-templates/package.json", "build/libs/html-templates/package.json" ); +fs.copyFileSync( + "../libs/html-templates/package.json", + "build/libs/html-templates/package.json", +); const removeFromFileLinesThatInclude = (filePath, regex) => { let data = fs.readFileSync(filePath, "utf8"); @@ -55,13 +58,13 @@ removeFromFileLinesThatInclude(htmlPackageJson, /"types": "src\/index.ts",?/); replaceInFileSync( htmlPackageJson, /"main": "src\/index.ts"/, - '"main": "src/index.js"' + '"main": "src/index.js"', ); removeFromFileLinesThatInclude(sharedPackageJson, /"types": "src\/index.ts",?/); replaceInFileSync( sharedPackageJson, /"main": "src\/index.ts"/, - '"main": "src/index.js"' + '"main": "src/index.js"', ); // change ts-node scripts to node scripts @@ -70,14 +73,14 @@ replaceInFileSync(backPackageJson, /"node (.*)(\.ts)/g, '"node $1.js'); replaceInFileSync( backPackageJson, /--compilerOptions '{\\"resolveJsonModule\\": true}'/g, - "" + "", ); // change migration script from ts source files to js replaceInFileSync( backPackageJson, /"node_modules\/node-pg-migrate\/bin\/node-pg-migrate -j ts"/g, - '"node_modules/node-pg-migrate/bin/node-pg-migrate"' + '"node_modules/node-pg-migrate/bin/node-pg-migrate"', ); execSync("cp -r -v scalingo/. build/");