From d0fc4408522d05b44c9dae4cd10d69eb53d89a63 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 21 Sep 2023 15:44:24 +0100 Subject: [PATCH 1/7] Add `ar-ci.sh` script to run AR build in Github Actions Co-authored-by: George B <705427+georgeblahblah@users.noreply.github.com> --- .github/workflows/ar-ci.yml | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/ar-ci.yml diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml new file mode 100644 index 00000000000..e1b85d67592 --- /dev/null +++ b/.github/workflows/ar-ci.yml @@ -0,0 +1,73 @@ +name: "AR CI" + +on: + push: + + workflow_dispatch: + +# Allow queued workflows to interrupt previous runs +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + +# Allow GitHub to request an OIDC JWT ID token, to use with aws-actions/configure-aws-credentials +permissions: + id-token: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + # Checkout the repository + steps: + - uses: actions/checkout@v4 + + # Get the desired version of Node installed + - uses: actions/setup-node@v3 + with: + node-version-file: .nvmrc + + - name: Install dependencies + run: | + npm i -g yarn@1.x + yarn --silent --frozen-lockfile + + # Execute some tasks from the `apps-rendering/package.json` file, using `yarn` + - name: Build and package + working-directory: apps-rendering + run: | + yarn test + yarn build:client:prod + yarn build:server:prod + yarn copy-manifest + yarn copy-fonts + yarn synth + zip -r dist/server/mobile-apps-rendering.zip dist/server + + - name: AWS Auth + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }} + aws-region: eu-west-1 + + - name: Upload to riff-raff + uses: guardian/actions-riff-raff@v2.2.2 + with: + configPath: apps-rendering/riff-raff.yaml + projectName: Mobile::mobile-apps-rendering + buildNumberOffset: 22000 # This is the last build number from TeamCity + contentDirectories: | + mobile-apps-rendering-cfn: + - cdk/cdk.out/MobileAppsRendering-CODE.template.json + - cdk/cdk.out/MobileAppsRendering-PROD.template.json + mobile-apps-rendering-preview-cfn: + - cdk/cdk.out/MobileAppsRenderingPreview-CODE.template.json + - cdk/cdk.out/MobileAppsRenderingPreview-PROD.template.json + mobile-apps-rendering: + - dist/server/mobile-apps-rendering.zip + mobile-assets: + - dist/assets/manifest.json + - dist/assets/fonts + - dist/assets/ + From 4693b7401fe7aa50dbaa436b4ff904616daefa8b Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 21 Sep 2023 15:55:40 +0100 Subject: [PATCH 2/7] Ignore `dotcom-rendring` path when running AR build Also, increase `buildNumberOffset` to 27000. Co-authored-by: George B <705427+georgeblahblah@users.noreply.github.com> --- .github/workflows/ar-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml index e1b85d67592..026c7275df9 100644 --- a/.github/workflows/ar-ci.yml +++ b/.github/workflows/ar-ci.yml @@ -2,6 +2,8 @@ name: "AR CI" on: push: + paths-ignore: + - "dotcom-rendering/**" workflow_dispatch: @@ -56,7 +58,7 @@ jobs: with: configPath: apps-rendering/riff-raff.yaml projectName: Mobile::mobile-apps-rendering - buildNumberOffset: 22000 # This is the last build number from TeamCity + buildNumberOffset: 27000 # This is the last build number from TeamCity contentDirectories: | mobile-apps-rendering-cfn: - cdk/cdk.out/MobileAppsRendering-CODE.template.json From 5d2aad7bf7b3ebefd5b6464e82f30d9955edb60d Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 21 Sep 2023 15:58:09 +0100 Subject: [PATCH 3/7] Fix paths in `contentDirectories` when uploading artifacts Co-authored-by: George B <705427+georgeblahblah@users.noreply.github.com> --- .github/workflows/ar-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml index 026c7275df9..67e5c91ec3d 100644 --- a/.github/workflows/ar-ci.yml +++ b/.github/workflows/ar-ci.yml @@ -61,15 +61,15 @@ jobs: buildNumberOffset: 27000 # This is the last build number from TeamCity contentDirectories: | mobile-apps-rendering-cfn: - - cdk/cdk.out/MobileAppsRendering-CODE.template.json - - cdk/cdk.out/MobileAppsRendering-PROD.template.json + - apps-rendering/cdk/cdk.out/MobileAppsRendering-CODE.template.json + - apps-rendering/cdk/cdk.out/MobileAppsRendering-PROD.template.json mobile-apps-rendering-preview-cfn: - - cdk/cdk.out/MobileAppsRenderingPreview-CODE.template.json - - cdk/cdk.out/MobileAppsRenderingPreview-PROD.template.json + - apps-rendering/cdk/cdk.out/MobileAppsRenderingPreview-CODE.template.json + - apps-rendering/cdk/cdk.out/MobileAppsRenderingPreview-PROD.template.json mobile-apps-rendering: - - dist/server/mobile-apps-rendering.zip + - apps-rendering/dist/server/mobile-apps-rendering.zip mobile-assets: - - dist/assets/manifest.json - - dist/assets/fonts - - dist/assets/ + - apps-rendering/dist/assets/manifest.json + - apps-rendering/dist/assets/fonts + - apps-rendering/dist/assets/ From 241b4b6cec1d8cd0c450180554eb169053ee052e Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 21 Sep 2023 16:11:36 +0100 Subject: [PATCH 4/7] Fix paths in `contentDirectories` --- .github/workflows/ar-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml index 67e5c91ec3d..dfac71c1c87 100644 --- a/.github/workflows/ar-ci.yml +++ b/.github/workflows/ar-ci.yml @@ -61,11 +61,11 @@ jobs: buildNumberOffset: 27000 # This is the last build number from TeamCity contentDirectories: | mobile-apps-rendering-cfn: - - apps-rendering/cdk/cdk.out/MobileAppsRendering-CODE.template.json - - apps-rendering/cdk/cdk.out/MobileAppsRendering-PROD.template.json + - apps-rendering/cdk.out/MobileAppsRendering-CODE.template.json + - apps-rendering/cdk.out/MobileAppsRendering-PROD.template.json mobile-apps-rendering-preview-cfn: - - apps-rendering/cdk/cdk.out/MobileAppsRenderingPreview-CODE.template.json - - apps-rendering/cdk/cdk.out/MobileAppsRenderingPreview-PROD.template.json + - apps-rendering/cdk.out/MobileAppsRenderingPreview-CODE.template.json + - apps-rendering/cdk.out/MobileAppsRenderingPreview-PROD.template.json mobile-apps-rendering: - apps-rendering/dist/server/mobile-apps-rendering.zip mobile-assets: From a3a545f1fcb76518eb4423ba99960c98a688c117 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 21 Sep 2023 17:52:35 +0100 Subject: [PATCH 5/7] Upload mobile-assets once in Riff-Raff `apps-rendering/dist/assets/` contains `apps-rendering/dist/assets/manifest.json` and `apps-rendering/dist/assets/fonts` so no need to refer to those. --- .github/workflows/ar-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml index dfac71c1c87..a98d96db3c4 100644 --- a/.github/workflows/ar-ci.yml +++ b/.github/workflows/ar-ci.yml @@ -69,7 +69,5 @@ jobs: mobile-apps-rendering: - apps-rendering/dist/server/mobile-apps-rendering.zip mobile-assets: - - apps-rendering/dist/assets/manifest.json - - apps-rendering/dist/assets/fonts - apps-rendering/dist/assets/ From 7017cb18d3f416164bdbadc6558ac1e51e410865 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Fri, 22 Sep 2023 15:50:13 +0100 Subject: [PATCH 6/7] Zip only the contents of `dist/server` and not the file structure Previous structure when unzipping was mobile-apps-rendering -> dist -> server -> . This was breaking deployment. After this change structure will be the expected mobile-apps-rendering -> Co-authored-by: George B <705427+georgeblahblah@users.noreply.github.com> --- .github/workflows/ar-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml index a98d96db3c4..bf07e33705c 100644 --- a/.github/workflows/ar-ci.yml +++ b/.github/workflows/ar-ci.yml @@ -45,7 +45,7 @@ jobs: yarn copy-manifest yarn copy-fonts yarn synth - zip -r dist/server/mobile-apps-rendering.zip dist/server + zip -j dist/server/mobile-apps-rendering.zip dist/server/* - name: AWS Auth uses: aws-actions/configure-aws-credentials@v2 From 83f2d35dd3397a38bf7814ce77bf1bc37cd87394 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Mon, 25 Sep 2023 11:39:49 +0100 Subject: [PATCH 7/7] Cache dependencies in the workflow See more: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#about-caching-workflow-dependencies Also, do not install yarn separately. Co-authored-by: George B <705427+georgeblahblah@users.noreply.github.com> Co-authored-by: DanielCliftonGuardian <110032454+DanielCliftonGuardian@users.noreply.github.com> --- .github/workflows/ar-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ar-ci.yml b/.github/workflows/ar-ci.yml index bf07e33705c..9f7b7c8f7df 100644 --- a/.github/workflows/ar-ci.yml +++ b/.github/workflows/ar-ci.yml @@ -28,11 +28,11 @@ jobs: # Get the desired version of Node installed - uses: actions/setup-node@v3 with: + cache: yarn node-version-file: .nvmrc - name: Install dependencies run: | - npm i -g yarn@1.x yarn --silent --frozen-lockfile # Execute some tasks from the `apps-rendering/package.json` file, using `yarn`