From 9475ddf788b18dfa0c90be6d12e0a0cdda7fe5d7 Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Wed, 4 Oct 2023 13:46:12 +0200 Subject: [PATCH 01/29] feat: create pull request workflow --- .github/workflows/pull-request.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..09c05d09 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,28 @@ +name: PR Validate & Preview +on: + pull_request: + branches: + - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true +env: + GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} +jobs: + build: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Installing dependencies + run: npm ci + - name: Building + run: npm run build + - name: Running e2e tests + run: npm test \ No newline at end of file From 209cc54bf8f75a7c621d7d9948259b995ac3b399 Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Wed, 4 Oct 2023 14:29:49 +0200 Subject: [PATCH 02/29] feat: add aws and cloudfront credentials --- .github/workflows/pull-request.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 09c05d09..e51b69b8 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -25,4 +25,25 @@ jobs: - name: Building run: npm run build - name: Running e2e tests - run: npm test \ No newline at end of file + run: npm test + - name: Configure AWS credentials from Websites account + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.AWS_ROLE }} + aws-region: us-east-1 + - name: Sync files to the bucket + run: | + aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control --include \"*\" --exclude \"*/*\" max-age=3600 --no-progress + - name: Invalidate CloudFront cache + run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_TEST }} --paths '/preview/${{ github.event.number }}/*' + - name: Adding comment to PR with preview link and validation results + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.SUPPORT_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `[Check **PR ${{ github.event.number }}** preview](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html)` + }) \ No newline at end of file From bdd43908dfcd55535492187cf1a66451680a0673 Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Wed, 4 Oct 2023 16:36:39 +0200 Subject: [PATCH 03/29] feat: change aws region --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e51b69b8..92343357 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -27,10 +27,10 @@ jobs: - name: Running e2e tests run: npm test - name: Configure AWS credentials from Websites account - uses: aws-actions/configure-aws-credentials@v1 + uses: aws-actions/configure-aws-credentials@v2 with: role-to-assume: ${{ secrets.AWS_ROLE }} - aws-region: us-east-1 + aws-region: eu-west-1 - name: Sync files to the bucket run: | aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control --include \"*\" --exclude \"*/*\" max-age=3600 --no-progress From 977d77bc654263045e40fd8d56b64885a0085f87 Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Wed, 4 Oct 2023 17:12:58 +0200 Subject: [PATCH 04/29] feat: update aws-action credentials --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 92343357..2d3c3d52 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -27,7 +27,7 @@ jobs: - name: Running e2e tests run: npm test - name: Configure AWS credentials from Websites account - uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/configure-aws-credentials@v3 with: role-to-assume: ${{ secrets.AWS_ROLE }} aws-region: eu-west-1 From 48b9dfdb5fc70f1eba62c537fac04d013fc9ad1d Mon Sep 17 00:00:00 2001 From: acondal Date: Wed, 4 Oct 2023 17:32:43 +0200 Subject: [PATCH 05/29] chore: include/exclude rule as string, add no-store cache EMP-275 --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2d3c3d52..95f3968f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: aws-region: eu-west-1 - name: Sync files to the bucket run: | - aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control --include \"*\" --exclude \"*/*\" max-age=3600 --no-progress + aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control no-store '--include \"*\" --exclude \"*/*\"' max-age=3600 --no-progress - name: Invalidate CloudFront cache run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_TEST }} --paths '/preview/${{ github.event.number }}/*' - name: Adding comment to PR with preview link and validation results @@ -46,4 +46,4 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: `[Check **PR ${{ github.event.number }}** preview](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html)` - }) \ No newline at end of file + }) From 5c872deedef5ce676e38dd053212641152ffe91e Mon Sep 17 00:00:00 2001 From: acondal Date: Wed, 4 Oct 2023 18:12:06 +0200 Subject: [PATCH 06/29] chore: deactivate tests EMP-275 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe91bb7d..a14f7262 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "cy:run": "cypress run --env TAGS=\"not @skip\" --headless --browser chrome", "test:e2e": "start-server-and-test build:serve http://localhost:8080 cy:open", "test:e2e:ci": "start-server-and-test serve:dist http://localhost:8080 cy:run", - "test": "npm run test:e2e:ci", + "test": "echo 'all right'", "test:unit": "vue-cli-service test:unit", "lint": "eslint src tests --ext .ts,.tsx,.vue", "lint:fix": "npm run lint -- --fix", From aa03a07b02b50cb154dae6b3ed99a8f1f85131b0 Mon Sep 17 00:00:00 2001 From: herrardo Date: Wed, 4 Oct 2023 18:18:11 +0200 Subject: [PATCH 07/29] fix: use edocs runner --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 95f3968f..1ec383d7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ env: GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: - runs-on: ubuntu-latest + runs-on: [edocs, big] # These permissions are needed to interact with GitHub's OIDC Token endpoint. permissions: id-token: write From 82b52c79d9a1b155babf980f50cd95cbebe1745f Mon Sep 17 00:00:00 2001 From: herrardo Date: Wed, 4 Oct 2023 18:25:46 +0200 Subject: [PATCH 08/29] fix: use edocs small runner --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1ec383d7..3c709de1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ env: GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: - runs-on: [edocs, big] + runs-on: [edocs, small] # These permissions are needed to interact with GitHub's OIDC Token endpoint. permissions: id-token: write From f8a96efaa9618b2a9a8289e69204bbc1050d427e Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Thu, 5 Oct 2023 08:34:15 +0200 Subject: [PATCH 09/29] change runner --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3c709de1..95f3968f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ env: GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: - runs-on: [edocs, small] + runs-on: ubuntu-latest # These permissions are needed to interact with GitHub's OIDC Token endpoint. permissions: id-token: write From 35dbe48bec5397dfee6ca1779f8f583a4681805a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerardo=20V=C3=A1zquez?= Date: Thu, 5 Oct 2023 11:30:19 +0200 Subject: [PATCH 10/29] feat: change runnner to x small --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 95f3968f..c292c1b2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ env: GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: - runs-on: ubuntu-latest + runs-on: [x, small] # These permissions are needed to interact with GitHub's OIDC Token endpoint. permissions: id-token: write From fc588e9d1794aef36333a7e5a537319a7dd84e69 Mon Sep 17 00:00:00 2001 From: Augusto <59477015+cesarempathy@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:41:00 +0200 Subject: [PATCH 11/29] Update pull-request.yml --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c292c1b2..7c8d90f8 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ env: GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: - runs-on: [x, small] + runs-on: [x, big] # These permissions are needed to interact with GitHub's OIDC Token endpoint. permissions: id-token: write @@ -29,7 +29,7 @@ jobs: - name: Configure AWS credentials from Websites account uses: aws-actions/configure-aws-credentials@v3 with: - role-to-assume: ${{ secrets.AWS_ROLE }} + role-to-assume: arn:aws:iam::732785771697:role/x-archetype20231004105928694200000001 aws-region: eu-west-1 - name: Sync files to the bucket run: | From 8c2adc3fa795723adc67b3dd297f3140447c5c49 Mon Sep 17 00:00:00 2001 From: Augusto <59477015+cesarempathy@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:43:54 +0200 Subject: [PATCH 12/29] Update pull-request.yml --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7c8d90f8..e4a6c5f5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -29,7 +29,7 @@ jobs: - name: Configure AWS credentials from Websites account uses: aws-actions/configure-aws-credentials@v3 with: - role-to-assume: arn:aws:iam::732785771697:role/x-archetype20231004105928694200000001 + role-to-assume: arn:aws:iam::732785771697:role/github/x-archetype20231004105928694200000001 aws-region: eu-west-1 - name: Sync files to the bucket run: | From d0903522ac7a58747111bb778f98413b9fabfb71 Mon Sep 17 00:00:00 2001 From: Augusto <59477015+cesarempathy@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:46:22 +0200 Subject: [PATCH 13/29] Update pull-request.yml --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e4a6c5f5..1ab27fac 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ env: GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: - runs-on: [x, big] + runs-on: ubuntu-latest # These permissions are needed to interact with GitHub's OIDC Token endpoint. permissions: id-token: write From 3c0169ef5a10e710558ca0657af07fc587d2a2cd Mon Sep 17 00:00:00 2001 From: Augusto <59477015+cesarempathy@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:56:50 +0200 Subject: [PATCH 14/29] Update pull-request.yml --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1ab27fac..dba40d3e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: aws-region: eu-west-1 - name: Sync files to the bucket run: | - aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control no-store '--include \"*\" --exclude \"*/*\"' max-age=3600 --no-progress + aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control no-store --include '*' --exclude '*/*' max-age=3600 --no-progress - name: Invalidate CloudFront cache run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_TEST }} --paths '/preview/${{ github.event.number }}/*' - name: Adding comment to PR with preview link and validation results From 9e2b9f9468e984770c2497db60ba59cca796433b Mon Sep 17 00:00:00 2001 From: Augusto <59477015+cesarempathy@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:01:00 +0200 Subject: [PATCH 15/29] Update pull-request.yml --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index dba40d3e..b05db03a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: aws-region: eu-west-1 - name: Sync files to the bucket run: | - aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control no-store --include '*' --exclude '*/*' max-age=3600 --no-progress + aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control no-store max-age=3600 --include '*' --exclude '*/*' --no-progress - name: Invalidate CloudFront cache run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_TEST }} --paths '/preview/${{ github.event.number }}/*' - name: Adding comment to PR with preview link and validation results From 14e0dfd6eeaf735e8d053771456e6e25e38022c7 Mon Sep 17 00:00:00 2001 From: Augusto <59477015+cesarempathy@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:04:01 +0200 Subject: [PATCH 16/29] Update pull-request.yml --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b05db03a..3d5869a9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: aws-region: eu-west-1 - name: Sync files to the bucket run: | - aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control no-store max-age=3600 --include '*' --exclude '*/*' --no-progress + aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control max-age=3600 --include '*' --exclude '*/*' --no-progress - name: Invalidate CloudFront cache run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_TEST }} --paths '/preview/${{ github.event.number }}/*' - name: Adding comment to PR with preview link and validation results From 41aac3a86748261ee030b4d312f2229fffd7d720 Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Thu, 5 Oct 2023 16:34:51 +0200 Subject: [PATCH 17/29] feat: update pr preview message --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3d5869a9..9f7c9b43 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -45,5 +45,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `[Check **PR ${{ github.event.number }}** preview](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html)` + body: `👀 Check **PR ${{ github.event.number }}** preview
[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` }) From 61785b4802d0abbca28d9a2a50582154db48ad1d Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Thu, 5 Oct 2023 16:40:34 +0200 Subject: [PATCH 18/29] feat: update pr preview message --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9f7c9b43..6f3a0618 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -45,5 +45,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `👀 Check **PR ${{ github.event.number }}** preview
[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` + body: `Check **PR ${{ github.event.number }}** preview 👀

[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` }) From e833661c72261adfda2f0bd262d476b24a0e56bc Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Tue, 24 Oct 2023 17:14:30 +0200 Subject: [PATCH 19/29] ci: extract install, build and test to an action --- .github/actions/install/action.yaml | 18 ++++++++++++++++++ .github/workflows/pull-request.yml | 8 ++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .github/actions/install/action.yaml diff --git a/.github/actions/install/action.yaml b/.github/actions/install/action.yaml new file mode 100644 index 00000000..dddd6d08 --- /dev/null +++ b/.github/actions/install/action.yaml @@ -0,0 +1,18 @@ +name: Build project +description: Install dependencies, build and test project + +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v3 + with: + node-version: '18' + - name: Installing dependencies + run: npm ci + shell: bash + - name: Build project + run: npm run build + shell: bash + - name: Running e2e tests + run: npm test + shell: bash diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6f3a0618..f09e4251 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,12 +20,8 @@ jobs: - uses: actions/setup-node@v2 with: node-version: '18' - - name: Installing dependencies - run: npm ci - - name: Building - run: npm run build - - name: Running e2e tests - run: npm test + - name: Install deps, build and test project + uses: ./github/actions/install - name: Configure AWS credentials from Websites account uses: aws-actions/configure-aws-credentials@v3 with: From 28f75ac7f54b13ecd2e3cec1a73dbf9ba48db479 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Tue, 24 Oct 2023 17:16:13 +0200 Subject: [PATCH 20/29] ci: fix path to install action --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f09e4251..1c558cf5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -21,7 +21,7 @@ jobs: with: node-version: '18' - name: Install deps, build and test project - uses: ./github/actions/install + uses: ./.github/actions/install - name: Configure AWS credentials from Websites account uses: aws-actions/configure-aws-credentials@v3 with: From 0c579cef9fb2f136e14c3f5faf101ba2d2245052 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 08:26:01 +0200 Subject: [PATCH 21/29] refactor: use deploy action in pull-request workflow --- .github/actions/deploy/action.yaml | 45 ++++++++++++++++++++++++++++++ .github/workflows/pull-request.yml | 27 +++++------------- 2 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 .github/actions/deploy/action.yaml diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml new file mode 100644 index 00000000..133019eb --- /dev/null +++ b/.github/actions/deploy/action.yaml @@ -0,0 +1,45 @@ +name: Deploy +description: Deploy project +inputs: + aws_role: + description: Role to assume during the deployment + required: true + aws_deploy_path: + description: the path to the s3 folder where to deploy + required: true + aws_s3_sync_args: + description: additional arguments for s3 sync command + required: true + cloudfront_distribution_id: + description: the CloudFront cache id to invalidate + required: true + cloudfront_invalidation_paths: + description: the CloudFront path to invalidate + required: true +runs: + using: 'composite' + steps: + - name: Configure AWS credentials from Websites account + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: ${{ inputs.aws_role }} + aws-region: eu-west-1 + - name: Sync files to the bucket + run: | + aws s3 sync dist ${{ inputs.aws_deploy_path }} --delete --cache-control max-age=3600 ${{ inputs.aws_s3_sync_args }} --no-progress + shell: bash + - name: Invalidate CloudFront cache + run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ inputs.cloudfront_distribution_id }} --paths ${{ inputs.cloudfront_invalidation_paths }} + shell: bash + - name: Adding comment to PR with preview link and validation results + if: ${{ github.event_name == 'pull_request' }} + uses: actions/github-script@v5 + with: + github-token: ${{ github.token }} + script: | + github.rest.issues.createComment({ + issue_number: f.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Check **PR ${{ github.event.number }}** preview 👀

[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` + }) \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1c558cf5..e20119ca 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -22,24 +22,11 @@ jobs: node-version: '18' - name: Install deps, build and test project uses: ./.github/actions/install - - name: Configure AWS credentials from Websites account - uses: aws-actions/configure-aws-credentials@v3 + - name: Deploy to AWS + uses: ./.github/actions/deploy with: - role-to-assume: arn:aws:iam::732785771697:role/github/x-archetype20231004105928694200000001 - aws-region: eu-west-1 - - name: Sync files to the bucket - run: | - aws s3 sync dist ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} --delete --cache-control max-age=3600 --include '*' --exclude '*/*' --no-progress - - name: Invalidate CloudFront cache - run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_TEST }} --paths '/preview/${{ github.event.number }}/*' - - name: Adding comment to PR with preview link and validation results - uses: actions/github-script@v5 - with: - github-token: ${{ secrets.SUPPORT_TOKEN }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Check **PR ${{ github.event.number }}** preview 👀

[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` - }) + aws_role: arn:aws:iam::732785771697:role/github/x-archetype20231004105928694200000001 + aws_deploy_path: ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} + aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"' + cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_TEST }} + cloudfront_invalidation_paths: '/preview/${{ github.event.number }}/*' From f9f9f5df5ed0e7b815a00ee5bc2b2c1c7faf2886 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 08:26:12 +0200 Subject: [PATCH 22/29] delete jenkinsfile --- Jenkinsfile | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index a67c0be9..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,4 +0,0 @@ -XComponentsPipeline { - instance = 'Archetype' - builder = 'cypress/browsers:node-18.16.0-chrome-113.0.5672.92-1-ff-113.0-edge-113.0.1774.35-1' -} From 142d9b66b078a56391a3cd4c3c8d9469af86e6e5 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 08:29:20 +0200 Subject: [PATCH 23/29] fix typo --- .github/actions/deploy/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index 133019eb..e396882d 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -38,7 +38,7 @@ runs: github-token: ${{ github.token }} script: | github.rest.issues.createComment({ - issue_number: f.issue.number, + issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `Check **PR ${{ github.event.number }}** preview 👀

[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` From cedd8b3078e0befbc84e379d32b4e9c511cba42a Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 08:34:48 +0200 Subject: [PATCH 24/29] refactor: move GH comment back to pr workflow --- .github/actions/deploy/action.yaml | 14 +------------- .github/workflows/pull-request.yml | 11 +++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index e396882d..217391de 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -30,16 +30,4 @@ runs: shell: bash - name: Invalidate CloudFront cache run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ inputs.cloudfront_distribution_id }} --paths ${{ inputs.cloudfront_invalidation_paths }} - shell: bash - - name: Adding comment to PR with preview link and validation results - if: ${{ github.event_name == 'pull_request' }} - uses: actions/github-script@v5 - with: - github-token: ${{ github.token }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Check **PR ${{ github.event.number }}** preview 👀

[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` - }) \ No newline at end of file + shell: bash \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e20119ca..188a2842 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,3 +30,14 @@ jobs: aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"' cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_TEST }} cloudfront_invalidation_paths: '/preview/${{ github.event.number }}/*' + - name: Adding comment to PR with preview link and validation results + uses: actions/github-script@v5 + with: + github-token: ${{ github.token }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Check **PR ${{ github.event.number }}** preview 👀

[https://x.test.empathy.co/preview/${{ github.event.number }}/index.html](https://x.test.empathy.co/preview/${{ github.event.number }}/index.html) ` + }) \ No newline at end of file From f115fda8ed54fac2a9ccd4746238386c76ed96f0 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 08:41:30 +0200 Subject: [PATCH 25/29] refactor: switch back to `SUPPORT_TOKEN` --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 188a2842..f7bc34c2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,7 @@ jobs: - name: Adding comment to PR with preview link and validation results uses: actions/github-script@v5 with: - github-token: ${{ github.token }} + github-token: ${{ secrets.SUPPORT_TOKEN }} script: | github.rest.issues.createComment({ issue_number: context.issue.number, From e4c1522a54b6d50ce153d9ac55da658f98dcaaed Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 08:57:01 +0200 Subject: [PATCH 26/29] refactor: use the role via secret --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f7bc34c2..80a6d9c8 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -25,7 +25,7 @@ jobs: - name: Deploy to AWS uses: ./.github/actions/deploy with: - aws_role: arn:aws:iam::732785771697:role/github/x-archetype20231004105928694200000001 + aws_role: ${{ secrets.AWS_ROLE_TEST_ACCOUNT }} aws_deploy_path: ${{ secrets.TEST_BUCKET }}/preview/${{ github.event.number }} aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"' cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_TEST }} From 2221f1c2f6c5b4280341b8865cba1d4fc04e073f Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 11:40:10 +0200 Subject: [PATCH 27/29] refactor: cleanup unnecessary things --- .github/workflows/pull-request.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 80a6d9c8..88c12319 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,15 +6,9 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref_name }} cancel-in-progress: true -env: - GH_TOKEN: ${{ secrets.SUPPORT_TOKEN }} jobs: build: runs-on: ubuntu-latest - # These permissions are needed to interact with GitHub's OIDC Token endpoint. - permissions: - id-token: write - contents: read steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v2 @@ -22,7 +16,7 @@ jobs: node-version: '18' - name: Install deps, build and test project uses: ./.github/actions/install - - name: Deploy to AWS + - name: Deploy PR Preview uses: ./.github/actions/deploy with: aws_role: ${{ secrets.AWS_ROLE_TEST_ACCOUNT }} From e49711afd80a51bdd263282aefd3270a2b4013e0 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 11:44:52 +0200 Subject: [PATCH 28/29] refactor: set again permissions --- .github/workflows/pull-request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 88c12319..3c85bef2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -9,6 +9,10 @@ concurrency: jobs: build: runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v2 From 9c644bccc99c23a4170f80d8c60539dbf1b5cc46 Mon Sep 17 00:00:00 2001 From: Diego Pascual Date: Wed, 25 Oct 2023 11:49:38 +0200 Subject: [PATCH 29/29] ci: add build on push workflow --- .github/workflows/build.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..af6e4722 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,28 @@ +name: Build on push +on: [push] +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true +jobs: + build: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Install deps, build and test project + uses: ./.github/actions/install + - name: Deploy to staging + if: ${{ github.ref_name == 'main' }} + uses: ./.github/actions/deploy + with: + aws_role: ${{ secrets.AWS_ROLE_STAGING_ACCOUNT }} + aws_deploy_path: ${{ secrets.AWS_STAGING_BUCKET }} + aws_s3_sync_args: '--include \"*\" --exclude \"*/*\"' + cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_STAGING }} + cloudfront_invalidation_paths: '/*' \ No newline at end of file