From 4ea0fca6101a339000da5cd41e548657d5277c14 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:25:28 +0200 Subject: [PATCH 1/9] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 145e5b8..06e5113 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fullstackopen-cicd", - "version": "1.0.0", + "version": "1.0.1", "description": "Full Stack Open", "main": "src/index.js", "scripts": { From 5dae0eb81c151f1f754444022e7f4586a44b2667 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:27:07 +0200 Subject: [PATCH 2/9] Listen pull_request event for pipeline --- .github/workflows/pipeline.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4771f8a..c9fd5ee 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -2,8 +2,10 @@ name: Deployment Pipeline on: push: - branches: - - main + branches: [main] + pull_request: + branches: [main] + types: [opened, synchronize] jobs: deploy: From f04b1a0047149531388aa14f138edd1d18663679 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:35:52 +0200 Subject: [PATCH 3/9] Make deploy to work only on master --- .github/workflows/pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c9fd5ee..e689bf1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -32,10 +32,11 @@ jobs: start: npm run start-test wait-on: http://localhost:5000 - name: Deploy to Heroku + if: ${{ github.event_name == 'push' }} uses: akhileshns/heroku-deploy@v3.12.12 with: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{secrets.HEROKU_APP}} heroku_email: ${{secrets.HEROKU_API_EMAIL}} - healthcheck: "https://${{secrets.HEROKU_APP}}/health" + healthcheck: "https://${{secrets.HEROKU_APP}}.herokuapp.com/health" rollbackonhealthcheckfailed: true From f0e13e2df62d9515b7a678c6d2756715f15d3092 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:40:11 +0200 Subject: [PATCH 4/9] Avoid redudant builds --- .github/workflows/pipeline.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index e689bf1..b9100e4 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -11,6 +11,10 @@ jobs: deploy: runs-on: ubuntu-18.04 steps: + - name: Cancel Previous Redundant Builds + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} - uses: actions/checkout@v2 with: fetch-depth: 0 From 87129a315a4947442ae00e1b1e8461ca94d17d9e Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:41:22 +0200 Subject: [PATCH 5/9] Publish new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 06e5113..f0b0c2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fullstackopen-cicd", - "version": "1.0.1", + "version": "1.0.2", "description": "Full Stack Open", "main": "src/index.js", "scripts": { From f088aea10590d96fd3da5bf542f21dc3714857d1 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:41:44 +0200 Subject: [PATCH 6/9] Bump new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0b0c2d..c5d80c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fullstackopen-cicd", - "version": "1.0.2", + "version": "1.0.3", "description": "Full Stack Open", "main": "src/index.js", "scripts": { From 1106ee4e3aa014ebd526700af4d30bec313ec15f Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:53:47 +0200 Subject: [PATCH 7/9] Parallelize CI --- .github/workflows/pipeline.yml | 65 +++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b9100e4..9acaa93 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -8,13 +8,18 @@ on: types: [opened, synchronize] jobs: - deploy: + + avoid_reduncy: runs-on: ubuntu-18.04 steps: - name: Cancel Previous Redundant Builds uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} + + lint: + runs-on: ubuntu-18.04 + steps: - uses: actions/checkout@v2 with: fetch-depth: 0 @@ -25,16 +30,74 @@ jobs: run: npm ci - name: Lint run: npm run eslint + + build: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Install dependencies + run: npm ci - name: Build run: npm run build + - uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + + test: + needs: [lint, build] + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Install dependencies + run: npm ci + - uses: actions/download-artifact@v2 + with: + name: dist + path: dist - name: Test run: npm test + + e2e: + needs: [lint, build] + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Install dependencies + run: npm ci + - uses: actions/download-artifact@v2 + with: + name: dist + path: dist - name: E2E tests uses: cypress-io/github-action@v2 with: command: npm run test:e2e start: npm run start-test wait-on: http://localhost:5000 + + deploy: + needs: [tests, e2e] + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Deploy to Heroku if: ${{ github.event_name == 'push' }} uses: akhileshns/heroku-deploy@v3.12.12 From b8978863f44a3e35fcdbcc60ddb35b3750af3641 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:54:29 +0200 Subject: [PATCH 8/9] Fix wrong job tests --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 9acaa93..6b3284d 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -92,7 +92,7 @@ jobs: wait-on: http://localhost:5000 deploy: - needs: [tests, e2e] + needs: [test, e2e] runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 From 88ce00bdffe8c2982183ae796ed22ff5d30c1e64 Mon Sep 17 00:00:00 2001 From: midudev Date: Sun, 8 Aug 2021 21:57:58 +0200 Subject: [PATCH 9/9] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c5d80c6..27b0fb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fullstackopen-cicd", - "version": "1.0.3", + "version": "1.0.4", "description": "Full Stack Open", "main": "src/index.js", "scripts": {