From dd9fea5ca4a8a25be369d97cf458a0e78b4d4bd8 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sun, 1 Aug 2021 16:03:26 +1000 Subject: [PATCH 01/12] Add changes to enable heroku to build ts --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 12441fe8..c153c907 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "build": "tsc", - "start": "yarn build && node dist/src/index.js", + "start": "node dist/src/index.js", "start:local": "dotenv -e .env -- ts-node-dev --transpile-only src/index.ts | pino-pretty -c", "test": "yarn lint && yarn style:check && yarn test:unit && yarn test:functional", "lint": "eslint ./src ./test --ext .ts", @@ -15,6 +15,7 @@ "style:check": "prettier --check 'src/**/*.ts' 'test/**/*.ts'", "style:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'" }, + "postinstall": "yarn build", "engines": { "node": ">=14" }, "repository": { "type": "git", From 4c605e03cb25d934999338b3db66819b02005a1e Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sun, 1 Aug 2021 16:12:11 +1000 Subject: [PATCH 02/12] Change APP_PORT to PORT for heroku --- config/custom-environment-variables.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 709f659e..d22c0ba7 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -1,6 +1,6 @@ { "App": { - "port": "APP_PORT", + "port": "PORT", "database": { "mongoUrl": "MONGODB_URL" }, From 1dca79d7a06b9e0dd30f28c9f3c97956be5dcb3f Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sun, 1 Aug 2021 16:24:08 +1000 Subject: [PATCH 03/12] Add test heroku deploy --- .github/workflows/full-workflow.yml | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/full-workflow.yml b/.github/workflows/full-workflow.yml index 2c4fc859..abb59daf 100644 --- a/.github/workflows/full-workflow.yml +++ b/.github/workflows/full-workflow.yml @@ -36,15 +36,22 @@ jobs: - name: Run all tests run: yarn test - - shell: bash - if: github.ref == 'refs/heads/master' - name: Create SSH deployment key - env: - SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - run: ./scripts/deploy.sh - - - name: Deployment - if: github.ref == 'refs/heads/master' - run: git remote add umbler ssh://git@geonosis.deploy.umbler.com:9922/jy4xooxj/waldemarnt2-com.git && git push umbler master - env: - CI: true + #- shell: bash + #if: github.ref == 'refs/heads/master' + #name: Create SSH deployment key + #env: + #SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + #run: ./scripts/deploy.sh + + #- name: Deployment + #if: github.ref == 'refs/heads/master' + #run: git remote add umbler ssh://git@geonosis.deploy.umbler.com:9922/jy4xooxj/waldemarnt2-com.git && git push umbler master + #env: + #CI: true + + - uses: akhileshns/heroku-deploy@v3.12.12 + with: + heroku_api_key: ${{secrets.HEROKU_API_KEY}} + heroku_app_name: "peaceful-plateau-04699" + heroku_email: "waldemarnt@gmail.com" + buildpack: "https://github.com/zidizei/heroku-buildpack-tsc#v2.0" From efd48e9345bf6d2e289187c884e6b62eaabf90f7 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sun, 1 Aug 2021 16:25:38 +1000 Subject: [PATCH 04/12] Upgrade node version --- .github/workflows/full-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/full-workflow.yml b/.github/workflows/full-workflow.yml index abb59daf..a6ca5e83 100644 --- a/.github/workflows/full-workflow.yml +++ b/.github/workflows/full-workflow.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - node-version: [12.x] + node-version: [14.x] mongodb-version: [4.2] steps: From accec3d2884b384e6e4aeffcfa8b22e0bdd92fa9 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 10:07:11 +1000 Subject: [PATCH 05/12] Ensure at least Node 12 is available --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c153c907..4e08537c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "style:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'" }, "postinstall": "yarn build", - "engines": { "node": ">=14" }, + "engines": { "node": ">=12" }, "repository": { "type": "git", "url": "git+https://github.com/waldemarnt/node-typescript-api.git" From 9022589d779a0a7aee27c7a45dd5b935161d5066 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 10:16:36 +1000 Subject: [PATCH 06/12] Update pipeline logic --- .github/workflows/full-workflow.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/full-workflow.yml b/.github/workflows/full-workflow.yml index a6ca5e83..9dd5a741 100644 --- a/.github/workflows/full-workflow.yml +++ b/.github/workflows/full-workflow.yml @@ -3,7 +3,13 @@ name: Complete workflow -on: ['push', 'pull_request'] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: @@ -13,7 +19,7 @@ jobs: strategy: matrix: - node-version: [14.x] + node-version: [12.x] mongodb-version: [4.2] steps: @@ -36,20 +42,9 @@ jobs: - name: Run all tests run: yarn test - #- shell: bash - #if: github.ref == 'refs/heads/master' - #name: Create SSH deployment key - #env: - #SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - #run: ./scripts/deploy.sh - - #- name: Deployment - #if: github.ref == 'refs/heads/master' - #run: git remote add umbler ssh://git@geonosis.deploy.umbler.com:9922/jy4xooxj/waldemarnt2-com.git && git push umbler master - #env: - #CI: true - - - uses: akhileshns/heroku-deploy@v3.12.12 + - name: Deploy application + if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} + uses: akhileshns/heroku-deploy@v3.12.12 with: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: "peaceful-plateau-04699" From d6ca68acadf40755b51febadc5a4e39d227f2d84 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 10:18:02 +1000 Subject: [PATCH 07/12] Add support to master branch --- .github/workflows/full-workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/full-workflow.yml b/.github/workflows/full-workflow.yml index 9dd5a741..b411644c 100644 --- a/.github/workflows/full-workflow.yml +++ b/.github/workflows/full-workflow.yml @@ -7,9 +7,11 @@ on: push: branches: - main + - master pull_request: branches: - main + - master jobs: From 4b967bb6a76c9db191d0e8b5d03afc96c55fb474 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 10:20:22 +1000 Subject: [PATCH 08/12] Update git checkout --- .github/workflows/full-workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/full-workflow.yml b/.github/workflows/full-workflow.yml index b411644c..ace4c6b1 100644 --- a/.github/workflows/full-workflow.yml +++ b/.github/workflows/full-workflow.yml @@ -26,7 +26,6 @@ jobs: steps: - uses: actions/checkout@v2 - - run: git fetch --prune --unshallow - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 From bdd347fe2f6a2e663af159e3eeb6335b99ff9249 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 14:44:51 +1000 Subject: [PATCH 09/12] Release test heroku --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e08537c..f546fa83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typescript-api", - "version": "1.0.0", + "version": "1.0.1", "description": "Complete API built with Node.js and Typescript", "main": "index.js", "scripts": { From 58e25a15d8ff259132c433168ef07696dbc0ddf9 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 14:59:16 +1000 Subject: [PATCH 10/12] Change version back to 0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f546fa83..4e08537c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typescript-api", - "version": "1.0.1", + "version": "1.0.0", "description": "Complete API built with Node.js and Typescript", "main": "index.js", "scripts": { From 01bed97714dfcc68aeefb1e012f5bdb756a50227 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 15:00:25 +1000 Subject: [PATCH 11/12] Delete unncessary scripts --- scripts/deploy.sh | 9 --------- 1 file changed, 9 deletions(-) delete mode 100755 scripts/deploy.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100755 index 5f90b72e..00000000 --- a/scripts/deploy.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -# Init .ssh dir and expand $SSH_KEY -mkdir -p ~/.ssh -echo -e "${SSH_KEY//_/\\n}" > ~/.ssh/id_rsa -chmod 600 ~/.ssh/id_rsa - -# Add umbler's git to the list of known_hosts to prevent terminal for asking to confirm the host -ssh-keyscan -p 9922 -t rsa geonosis.deploy.umbler.com 2>&1 >> ~/.ssh/known_hosts From 5fa6b3b90a98f35dddd69d83c4e395c4da804624 Mon Sep 17 00:00:00 2001 From: Waldemar Date: Sat, 7 Aug 2021 15:02:54 +1000 Subject: [PATCH 12/12] Add support only to node 12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e08537c..c7758858 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "style:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'" }, "postinstall": "yarn build", - "engines": { "node": ">=12" }, + "engines": { "node": "12" }, "repository": { "type": "git", "url": "git+https://github.com/waldemarnt/node-typescript-api.git"