From 938ff68d3885bf06ee2c361f6da24fc812de9748 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Thu, 9 Feb 2023 12:17:04 -0300 Subject: [PATCH 01/13] refact: rename job --- .github/workflows/push-main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index ab1d78c74a..0c0f9f8fbd 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -69,7 +69,7 @@ jobs: path: ./editor.planx.uk/build if-no-files-found: error - preview: + pulumi: name: Pulumi Up needs: build_react runs-on: ubuntu-22.04 @@ -105,7 +105,7 @@ jobs: notifications: name: Notifications - needs: preview + needs: pulumi runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 From 886201f14c49c24751194c16ba85fef49addccc7 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Thu, 23 Feb 2023 14:16:40 -0300 Subject: [PATCH 02/13] refact: extract pull-request/build-react into a reusable workflow --- .github/workflows/build-react.yml | 61 ++++++++++++++++++++++++++++++ .github/workflows/pull-request.yml | 60 +++-------------------------- 2 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/build-react.yml diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml new file mode 100644 index 0000000000..de19b52a8a --- /dev/null +++ b/.github/workflows/build-react.yml @@ -0,0 +1,61 @@ +on: + workflow_call: +# inputs: +# config-path: +# required: true +# type: string + +jobs: + build_react: + name: Build React App + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: Cache build assets + id: cache-react-build-assets + uses: actions/cache@v3 + with: + path: ./${{ env.EDITOR_DIRECTORY }}/build + key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }} + - uses: pnpm/action-setup@v2.2.2 + if: steps.cache-react-build-assets.outputs.cache-hit != 'true' + with: + version: ${{ env.PNPM_VERSION }} + - uses: actions/setup-node@v2 + if: steps.cache-react-build-assets.outputs.cache-hit != 'true' + with: + node-version: ${{ env.NODE_VERSION }} + cache: "pnpm" + cache-dependency-path: "**/pnpm-lock.yaml" + - run: pnpm distribute ../${{ env.EDITOR_DIRECTORY }} + if: steps.cache-react-build-assets.outputs.cache-hit != 'true' + working-directory: core + - run: pnpm install --frozen-lockfile + if: steps.cache-react-build-assets.outputs.cache-hit != 'true' + working-directory: ${{ env.EDITOR_DIRECTORY }} + - run: pnpm build + if: steps.cache-react-build-assets.outputs.cache-hit != 'true' + env: + REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} + REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} + REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} + REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 + REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} + # needed because there's no API to change google's allowed OAuth URLs + REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev + REACT_APP_ENV: pizza + working-directory: ${{ env.EDITOR_DIRECTORY }} + - run: pnpm build-storybook + if: steps.cache-react-build-assets.outputs.cache-hit != 'true' + working-directory: ${{ env.EDITOR_DIRECTORY }} + env: + # same env as above, if it's job.env it can't access existing env.[variable] + REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} + REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} + REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} + REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 + REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} + REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev + REACT_APP_ENV: pizza diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5514833073..2f1f53f63a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -13,7 +13,7 @@ env: PULLREQUEST_ID: ${{ github.event.number }} EDITOR_DIRECTORY: editor.planx.uk PNPM_VERSION: 7.8.0 - NODE_VERSION: 16.13.1 # 16.13.1 = LTS + NODE_VERSION: 16.13.1 # 16.13.1 = LTS jobs: changes: @@ -172,60 +172,10 @@ jobs: working-directory: ${{ env.EDITOR_DIRECTORY }} build_react_app: + uses: ./.github/workflows/build-react.yml name: Build React App - runs-on: ubuntu-22.04 needs: [changes] if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" - steps: - - uses: actions/checkout@v2 - - name: Cache build assets - id: cache-react-build-assets - uses: actions/cache@v3 - with: - path: ./${{ env.EDITOR_DIRECTORY }}/build - key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }} - - uses: pnpm/action-setup@v2.2.2 - if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - with: - version: ${{ env.PNPM_VERSION }} - - uses: actions/setup-node@v2 - if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - with: - node-version: ${{ env.NODE_VERSION }} - cache: "pnpm" - cache-dependency-path: "**/pnpm-lock.yaml" - - run: pnpm distribute ../${{ env.EDITOR_DIRECTORY }} - if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: core - - run: pnpm install --frozen-lockfile - if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: ${{ env.EDITOR_DIRECTORY }} - - run: pnpm build - if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - env: - REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} - REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} - REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} - # needed because there's no API to change google's allowed OAuth URLs - REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev - REACT_APP_ENV: pizza - working-directory: ${{ env.EDITOR_DIRECTORY }} - - run: pnpm build-storybook - if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: ${{ env.EDITOR_DIRECTORY }} - env: - # same env as above, if it's job.env it can't access existing env.[variable] - REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} - REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} - REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} - REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev - REACT_APP_ENV: pizza pulumi_preview: name: Run Pulumi Preview @@ -427,13 +377,13 @@ jobs: uses: treosh/lighthouse-ci-action@v9 id: LHCIAction with: - urls: | + urls: | https://editor.planx.dev/buckinghamshire/find-out-if-you-need-planning-permission/preview https://${{ env.FULL_DOMAIN }}/buckinghamshire/find-out-if-you-need-planning-permission/preview https://editor.planx.dev/testing/lighthouse-canary-flow/unpublished https://${{ env.FULL_DOMAIN }}/testing/lighthouse-canary-flow/unpublished - uploadArtifacts: true # save results as an action artifacts - temporaryPublicStorage: true # upload lighthouse report to the temporary storage + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Interpolate comment text id: text uses: actions/github-script@v6 From a84e16e5d0d6d90321a876e60e92c661609b1240 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Thu, 23 Feb 2023 14:34:39 -0300 Subject: [PATCH 03/13] fix(ci): env vars --- .github/workflows/build-react.yml | 43 ++++++++++++++++++------------ .github/workflows/pull-request.yml | 7 ++++- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index de19b52a8a..5f99ed546d 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -1,9 +1,18 @@ on: workflow_call: -# inputs: -# config-path: -# required: true -# type: string + inputs: + PNPM_VERSION: + required: true + type: string + EDITOR_DIRECTORY: + required: true + type: string + NODE_VERSION: + required: true + type: string + FULL_DOMAIN: + required: true + type: string jobs: build_react: @@ -15,47 +24,47 @@ jobs: id: cache-react-build-assets uses: actions/cache@v3 with: - path: ./${{ env.EDITOR_DIRECTORY }}/build + path: ./${{ inputs.EDITOR_DIRECTORY }}/build key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }} - uses: pnpm/action-setup@v2.2.2 if: steps.cache-react-build-assets.outputs.cache-hit != 'true' with: - version: ${{ env.PNPM_VERSION }} + version: ${{ inputs.PNPM_VERSION }} - uses: actions/setup-node@v2 if: steps.cache-react-build-assets.outputs.cache-hit != 'true' with: - node-version: ${{ env.NODE_VERSION }} + node-version: ${{ inputs.NODE_VERSION }} cache: "pnpm" cache-dependency-path: "**/pnpm-lock.yaml" - - run: pnpm distribute ../${{ env.EDITOR_DIRECTORY }} + - run: pnpm distribute ../${{ inputs.EDITOR_DIRECTORY }} if: steps.cache-react-build-assets.outputs.cache-hit != 'true' working-directory: core - run: pnpm install --frozen-lockfile if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: ${{ env.EDITOR_DIRECTORY }} + working-directory: ${{ inputs.EDITOR_DIRECTORY }} - run: pnpm build if: steps.cache-react-build-assets.outputs.cache-hit != 'true' env: REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} + REACT_APP_API_URL: https://api.${{ inputs.FULL_DOMAIN }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ inputs.FULL_DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.FULL_DOMAIN }} # needed because there's no API to change google's allowed OAuth URLs REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev REACT_APP_ENV: pizza - working-directory: ${{ env.EDITOR_DIRECTORY }} + working-directory: ${{ inputs.EDITOR_DIRECTORY }} - run: pnpm build-storybook if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: ${{ env.EDITOR_DIRECTORY }} + working-directory: ${{ inputs.EDITOR_DIRECTORY }} env: # same env as above, if it's job.env it can't access existing env.[variable] REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} + REACT_APP_API_URL: https://api.${{ inputs.FULL_DOMAIN }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ inputs.FULL_DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.FULL_DOMAIN }} REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev REACT_APP_ENV: pizza diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2f1f53f63a..2e46c35f40 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -172,10 +172,15 @@ jobs: working-directory: ${{ env.EDITOR_DIRECTORY }} build_react_app: - uses: ./.github/workflows/build-react.yml name: Build React App needs: [changes] if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" + uses: ./.github/workflows/build-react.yml + with: + PNPM_VERSION: ${{ env.PNPM_VERSION }} + EDITOR_DIRECTORY: ${{ env.EDITOR_DIRECTORY }} + NODE_VERSION: ${{ env.NODE_VERSION }} + FULL_DOMAIN: ${{ env.FULL_DOMAIN }} pulumi_preview: name: Run Pulumi Preview From 1ece3788b9e84d03d597e141c589a6f206ba9a0a Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Mon, 27 Feb 2023 22:14:02 -0300 Subject: [PATCH 04/13] wip: .env --- .github/workflows/build-react.yml | 47 +++++++++++++++--------------- .github/workflows/constants.env | 6 ++++ .github/workflows/pull-request.yml | 5 ---- 3 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/constants.env diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index 5f99ed546d..c3e08352fd 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -1,17 +1,8 @@ on: workflow_call: inputs: - PNPM_VERSION: - required: true - type: string - EDITOR_DIRECTORY: - required: true - type: string - NODE_VERSION: - required: true - type: string - FULL_DOMAIN: - required: true + example: + required: false type: string jobs: @@ -20,51 +11,59 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 + - uses: cardinalby/export-env-action@v2 + with: + envFile: '.github/workflows/constants.env' + expand: true + expandWithJobEnv: true + - name: print all env vars + run: | + env - name: Cache build assets id: cache-react-build-assets uses: actions/cache@v3 with: - path: ./${{ inputs.EDITOR_DIRECTORY }}/build + path: ./${{ env.EDITOR_DIRECTORY }}/build key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }} - uses: pnpm/action-setup@v2.2.2 if: steps.cache-react-build-assets.outputs.cache-hit != 'true' with: - version: ${{ inputs.PNPM_VERSION }} + version: ${{ env.PNPM_VERSION }} - uses: actions/setup-node@v2 if: steps.cache-react-build-assets.outputs.cache-hit != 'true' with: - node-version: ${{ inputs.NODE_VERSION }} + node-version: ${{ env.NODE_VERSION }} cache: "pnpm" cache-dependency-path: "**/pnpm-lock.yaml" - - run: pnpm distribute ../${{ inputs.EDITOR_DIRECTORY }} + - run: pnpm distribute ../${{ env.EDITOR_DIRECTORY }} if: steps.cache-react-build-assets.outputs.cache-hit != 'true' working-directory: core - run: pnpm install --frozen-lockfile if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: ${{ inputs.EDITOR_DIRECTORY }} + working-directory: ${{ env.EDITOR_DIRECTORY }} - run: pnpm build if: steps.cache-react-build-assets.outputs.cache-hit != 'true' env: REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ inputs.FULL_DOMAIN }} + REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ inputs.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.FULL_DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} # needed because there's no API to change google's allowed OAuth URLs REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev REACT_APP_ENV: pizza - working-directory: ${{ inputs.EDITOR_DIRECTORY }} + working-directory: ${{ env.EDITOR_DIRECTORY }} - run: pnpm build-storybook if: steps.cache-react-build-assets.outputs.cache-hit != 'true' - working-directory: ${{ inputs.EDITOR_DIRECTORY }} + working-directory: ${{ env.EDITOR_DIRECTORY }} env: # same env as above, if it's job.env it can't access existing env.[variable] REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ inputs.FULL_DOMAIN }} + REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ inputs.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.FULL_DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev REACT_APP_ENV: pizza diff --git a/.github/workflows/constants.env b/.github/workflows/constants.env new file mode 100644 index 0000000000..fdb61d761d --- /dev/null +++ b/.github/workflows/constants.env @@ -0,0 +1,6 @@ +DOMAIN=planx.pizza +FULL_DOMAIN=${github.event.number}.planx.pizza +PULLREQUEST_ID=${github.event.number} +EDITOR_DIRECTORY=editor.planx.uk +PNPM_VERSION=7.8.0 +NODE_VERSION=16.13.1 # 16.13.1 = LTS diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2e46c35f40..fd1ebd0735 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -176,11 +176,6 @@ jobs: needs: [changes] if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" uses: ./.github/workflows/build-react.yml - with: - PNPM_VERSION: ${{ env.PNPM_VERSION }} - EDITOR_DIRECTORY: ${{ env.EDITOR_DIRECTORY }} - NODE_VERSION: ${{ env.NODE_VERSION }} - FULL_DOMAIN: ${{ env.FULL_DOMAIN }} pulumi_preview: name: Run Pulumi Preview From c127432bffc46fc2d133e4eadaffaa686b1b460f Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Mon, 27 Feb 2023 22:31:44 -0300 Subject: [PATCH 05/13] wip: remove dependency on github.event.number --- .github/workflows/build-react.yml | 12 ++++----- .github/workflows/constants.env | 2 -- .github/workflows/pull-request.yml | 42 ++++++++++++++---------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index c3e08352fd..633d2f7ef4 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -46,10 +46,10 @@ jobs: env: REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} + REACT_APP_API_URL: https://api.${{ github.event.number }}.${{ env.DOMAIN }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ github.event.number }}.${{ env.DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ github.event.number }}.${{ env.DOMAIN }} # needed because there's no API to change google's allowed OAuth URLs REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev REACT_APP_ENV: pizza @@ -61,9 +61,9 @@ jobs: # same env as above, if it's job.env it can't access existing env.[variable] REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ env.FULL_DOMAIN }} + REACT_APP_API_URL: https://api.${{ github.event.number }}.${{ env.DOMAIN }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ env.FULL_DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ env.FULL_DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ github.event.number }}.${{ env.DOMAIN }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ github.event.number }}.${{ env.DOMAIN }} REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev REACT_APP_ENV: pizza diff --git a/.github/workflows/constants.env b/.github/workflows/constants.env index fdb61d761d..7178d0fec9 100644 --- a/.github/workflows/constants.env +++ b/.github/workflows/constants.env @@ -1,6 +1,4 @@ DOMAIN=planx.pizza -FULL_DOMAIN=${github.event.number}.planx.pizza -PULLREQUEST_ID=${github.event.number} EDITOR_DIRECTORY=editor.planx.uk PNPM_VERSION=7.8.0 NODE_VERSION=16.13.1 # 16.13.1 = LTS diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fd1ebd0735..79e29f72d1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -9,8 +9,6 @@ on: env: DOMAIN: planx.pizza - FULL_DOMAIN: ${{ github.event.number }}.planx.pizza - PULLREQUEST_ID: ${{ github.event.number }} EDITOR_DIRECTORY: editor.planx.uk PNPM_VERSION: 7.8.0 NODE_VERSION: 16.13.1 # 16.13.1 = LTS @@ -226,7 +224,7 @@ jobs: id: hasura-change with: github_token: ${{ secrets.GITHUB_TOKEN }} - hasura_endpoint: https://hasura.${{ env.FULL_DOMAIN }} + hasura_endpoint: https://hasura.${{ github.event.number }}.${{ env.DOMAIN }} project_dir: ./hasura.planx.uk - uses: marocchino/sticky-pull-request-comment@v2 if: ${{steps.hasura-change.outputs.change_html != ''}} @@ -256,7 +254,7 @@ jobs: domain: ${{ env.DOMAIN }} os_id: 1743 plan: vc2-1c-1gb - pullrequest_id: ${{ env.PULLREQUEST_ID }} + pullrequest_id: ${{ github.event.number }} region: lhr tag: pullrequest @@ -266,14 +264,14 @@ jobs: name: Create commands uses: appleboy/ssh-action@master with: - host: ${{ env.FULL_DOMAIN }} + host: ${{ github.event.number }}.${{ env.DOMAIN }} username: root password: ${{ steps.create.outputs.default_password }} command_timeout: 20m script: | git clone "${{ secrets.AUTHENTICATED_REPO_URL }}" cd planx-new - git fetch origin "pull/${{ env.PULLREQUEST_ID }}/head" && git checkout FETCH_HEAD + git fetch origin "pull/${{ github.event.number }}/head" && git checkout FETCH_HEAD apt-get install awscli -y export AWS_ACCESS_KEY_ID=${{ secrets.PIZZA_AWS_ACCESS_KEY_ID }} @@ -282,7 +280,7 @@ jobs: ./scripts/pull-secrets.sh - echo -e "\nROOT_DOMAIN=${{ env.FULL_DOMAIN }}\n" > .env.temp + echo -e "\nROOT_DOMAIN=${{ github.event.number }}.${{ env.DOMAIN }}\n" > .env.temp cat .env .env.temp .env.staging > .env.pizza SSH_PASSWORD=${{ secrets.SSH_PASSWORD }} ./scripts/pullrequest/create.sh @@ -293,7 +291,7 @@ jobs: name: Update commands uses: appleboy/ssh-action@master with: - host: ${{ env.FULL_DOMAIN }} + host: ${{ github.event.number }}.${{ env.DOMAIN }} username: root password: ${{ secrets.SSH_PASSWORD }} command_timeout: 10m @@ -301,7 +299,7 @@ jobs: git clone "${{ secrets.AUTHENTICATED_REPO_URL }}" cd planx-new git add . && git stash - git fetch origin "pull/${{ env.PULLREQUEST_ID }}/head" && git checkout FETCH_HEAD + git fetch origin "pull/${{ github.event.number }}/head" && git checkout FETCH_HEAD apt-get install awscli -y export AWS_ACCESS_KEY_ID=${{ secrets.PIZZA_AWS_ACCESS_KEY_ID }} @@ -310,7 +308,7 @@ jobs: ./scripts/pull-secrets.sh - echo -e "\nROOT_DOMAIN=${{ env.FULL_DOMAIN }}\n" > .env.temp + echo -e "\nROOT_DOMAIN=${{ github.event.number }}.${{ env.DOMAIN }}\n" > .env.temp cat .env .env.temp .env.staging > .env.pizza ./scripts/pullrequest/update.sh @@ -327,7 +325,7 @@ jobs: - name: upload built editor uses: appleboy/scp-action@master with: - host: ${{ env.FULL_DOMAIN }} + host: ${{ github.event.number }}.${{ env.DOMAIN }} username: root password: ${{ secrets.SSH_PASSWORD }} source: "./${{ env.EDITOR_DIRECTORY }}/build" @@ -340,14 +338,14 @@ jobs: message: | ## Pizza - Deployed ${{ github.sha }} to https://${{ env.FULL_DOMAIN }}. + Deployed ${{ github.sha }} to https://${{ github.event.number }}.${{ env.DOMAIN }}. Useful links: - - [Editor](https://${{ env.FULL_DOMAIN }}) - - [Storybook](https://storybook.${{ env.FULL_DOMAIN }}) - - [Hasura](https://hasura.${{ env.FULL_DOMAIN }}) - - [API](https://api.${{ env.FULL_DOMAIN }}) - - [ShareDB](https://sharedb.${{ env.FULL_DOMAIN }}) + - [Editor](https://${{ github.event.number }}.${{ env.DOMAIN }}) + - [Storybook](https://storybook.${{ github.event.number }}.${{ env.DOMAIN }}) + - [Hasura](https://hasura.${{ github.event.number }}.${{ env.DOMAIN }}) + - [API](https://api.${{ github.event.number }}.${{ env.DOMAIN }}) + - [ShareDB](https://sharedb.${{ github.event.number }}.${{ env.DOMAIN }}) healthcheck: name: Run Healthcheck on Pizza Services @@ -356,15 +354,15 @@ jobs: steps: - name: API healthcheck run: | - timeout 150s bash -c "until curl --fail https://api.${{ env.FULL_DOMAIN }}; do sleep 1; done" + timeout 150s bash -c "until curl --fail https://api.${{ github.event.number }}.${{ env.DOMAIN }}; do sleep 1; done" - name: Hasura healthcheck run: | - timeout 150s bash -c "until curl --fail https://hasura.${{ env.FULL_DOMAIN }}/healthz; do sleep 1; done" + timeout 150s bash -c "until curl --fail https://hasura.${{ github.event.number }}.${{ env.DOMAIN }}/healthz; do sleep 1; done" - name: Editor healthcheck run: | - timeout 150s bash -c "until curl --fail https://${{ env.FULL_DOMAIN }}; do sleep 1; done" + timeout 150s bash -c "until curl --fail https://${{ github.event.number }}.${{ env.DOMAIN }}; do sleep 1; done" lighthouse: @@ -379,9 +377,9 @@ jobs: with: urls: | https://editor.planx.dev/buckinghamshire/find-out-if-you-need-planning-permission/preview - https://${{ env.FULL_DOMAIN }}/buckinghamshire/find-out-if-you-need-planning-permission/preview + https://${{ github.event.number }}.${{ env.DOMAIN }}/buckinghamshire/find-out-if-you-need-planning-permission/preview https://editor.planx.dev/testing/lighthouse-canary-flow/unpublished - https://${{ env.FULL_DOMAIN }}/testing/lighthouse-canary-flow/unpublished + https://${{ github.event.number }}.${{ env.DOMAIN }}/testing/lighthouse-canary-flow/unpublished uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage - name: Interpolate comment text From 0a9cb5098ef8639919dcd6a5ee2866dab2e6da2b Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Mon, 27 Feb 2023 23:13:22 -0300 Subject: [PATCH 06/13] wip: test conditional env --- .github/workflows/build-react.yml | 37 +++++++++++++------- .github/workflows/pull-request.yml | 3 ++ .github/workflows/push-main.yml | 56 ++++-------------------------- 3 files changed, 35 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index 633d2f7ef4..d1df83ad4a 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -1,8 +1,11 @@ on: workflow_call: inputs: - example: - required: false + target: + required: true + type: string + environment: + required: true type: string jobs: @@ -10,21 +13,24 @@ jobs: name: Build React App runs-on: ubuntu-22.04 steps: + - name: test conditional env + run: | + echo "${{ true && 'true' || 'false' }}" + echo "${{ false && 'true' || 'false' }}" + echo "${{ true && 'something' || '' }}" + echo "${{ false && 'something' || '' }}" - uses: actions/checkout@v2 - uses: cardinalby/export-env-action@v2 with: envFile: '.github/workflows/constants.env' expand: true expandWithJobEnv: true - - name: print all env vars - run: | - env - name: Cache build assets id: cache-react-build-assets uses: actions/cache@v3 with: path: ./${{ env.EDITOR_DIRECTORY }}/build - key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }} + key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }}-${{ inputs.target }} - uses: pnpm/action-setup@v2.2.2 if: steps.cache-react-build-assets.outputs.cache-hit != 'true' with: @@ -46,14 +52,21 @@ jobs: env: REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_API_URL: https://api.${{ github.event.number }}.${{ env.DOMAIN }} + REACT_APP_API_URL: https://api.${{ inputs.target }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.${{ github.event.number }}.${{ env.DOMAIN }}/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.${{ github.event.number }}.${{ env.DOMAIN }} + REACT_APP_HASURA_URL: https://hasura.${{ inputs.target }}/v1/graphql + REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.target }} + # TODO: this shouldn't be set for staging # needed because there's no API to change google's allowed OAuth URLs - REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev - REACT_APP_ENV: pizza + REACT_APP_GOOGLE_OAUTH_OVERRIDE: "${{ inputs.environment == 'pizza' && 'https://api.editor.planx.dev' || '' }}" + REACT_APP_ENV: ${{ inputs.environment }} working-directory: ${{ env.EDITOR_DIRECTORY }} + - name: Upload Build Artifact + uses: actions/upload-artifact@v2 + with: + name: build + path: ./editor.planx.uk/build + if-no-files-found: error - run: pnpm build-storybook if: steps.cache-react-build-assets.outputs.cache-hit != 'true' working-directory: ${{ env.EDITOR_DIRECTORY }} @@ -66,4 +79,4 @@ jobs: REACT_APP_HASURA_URL: https://hasura.${{ github.event.number }}.${{ env.DOMAIN }}/v1/graphql REACT_APP_SHAREDB_URL: wss://sharedb.${{ github.event.number }}.${{ env.DOMAIN }} REACT_APP_GOOGLE_OAUTH_OVERRIDE: https://api.editor.planx.dev - REACT_APP_ENV: pizza + REACT_APP_ENV: ${{ inputs.environment }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 79e29f72d1..553b7c42ec 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -174,6 +174,9 @@ jobs: needs: [changes] if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" uses: ./.github/workflows/build-react.yml + with: + target: "${{ github.event.number }}.${{ env.DOMAIN }}" + environment: "pizza" pulumi_preview: name: Run Pulumi Preview diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index 0c0f9f8fbd..30a8e42cb8 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -15,59 +15,17 @@ env: jobs: build_react: - name: Build React - runs-on: ubuntu-22.04 + name: Build React App + needs: [changes] + if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" + uses: ./.github/workflows/build-react.yml + with: + target: editor.planx.dev + environment: staging steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - # https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#using-the-cache-action - - name: NPM cache - uses: actions/cache@v2 - env: - cache-name: cache-npm - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: PNPM cache - uses: actions/cache@v2 - env: - cache-name: cache-pnpm - with: - # pnpm cache files are stored in `~/.local/share/pnpm/store` on Linux - path: ~/.local/share/pnpm/store - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - run: npm install -g pnpm@${{ env.PNPM_VERSION }} - - run: pnpm distribute ../editor.planx.uk - working-directory: core - - run: pnpm install --frozen-lockfile - working-directory: editor.planx.uk - run: pnpm build working-directory: editor.planx.uk env: - REACT_APP_API_URL: https://api.editor.planx.dev - REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.editor.planx.dev/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.editor.planx.dev - REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} - REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_ENV: staging - - name: Upload Build Artifact - uses: actions/upload-artifact@v2 - with: - name: build - path: ./editor.planx.uk/build - if-no-files-found: error pulumi: name: Pulumi Up From 285d20f98567384d1f0bd6e11f6837f6f66cfd30 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Mon, 27 Feb 2023 23:17:37 -0300 Subject: [PATCH 07/13] fix: env error --- .github/workflows/pull-request.yml | 5 ++++- .github/workflows/push-main.yml | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 553b7c42ec..d146515b21 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -175,7 +175,10 @@ jobs: if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" uses: ./.github/workflows/build-react.yml with: - target: "${{ github.event.number }}.${{ env.DOMAIN }}" + # TODO: replace `planx.pizza` for `${{ env.DOMAIN }}` + # although it's not possible to use env variables in `with` section + # you might be able to use `env` section to set `DOMAIN` variable + target: "${{ github.event.number }}.planx.pizza" environment: "pizza" pulumi_preview: diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index 30a8e42cb8..92c7f7df8e 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -22,10 +22,6 @@ jobs: with: target: editor.planx.dev environment: staging - steps: - - run: pnpm build - working-directory: editor.planx.uk - env: pulumi: name: Pulumi Up From 56641bbed74987a81bdb1f289814e8ccce5ca37b Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Tue, 28 Feb 2023 12:20:46 -0300 Subject: [PATCH 08/13] fix: get proper cache and fail on cache miss --- .github/workflows/pull-request.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d146515b21..d6911faeba 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -205,11 +205,11 @@ jobs: - run: pnpm install --frozen-lockfile working-directory: infrastructure/application - name: Download React build assets - id: cache-react-build-assets uses: actions/cache@v3 with: + fail-on-cache-miss: true path: ./${{ env.EDITOR_DIRECTORY }}/build - key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**', '!editor.planx/build/**') }} + key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**', '!editor.planx/build/**') }}-pizza - uses: pulumi/actions@v3 with: command: preview @@ -323,11 +323,11 @@ jobs: - uses: actions/checkout@v2 - name: Download React build assets - id: cache-react-build-assets uses: actions/cache@v3 with: + fail-on-cache-miss: true path: ./${{ env.EDITOR_DIRECTORY }}/build - key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**', '!editor.planx/build/**') }} + key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**', '!editor.planx/build/**') }}-pizza - name: upload built editor uses: appleboy/scp-action@master with: From 1fff077b941c987bf2bca1208d2bc8d6c1901d1f Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Tue, 28 Feb 2023 12:27:50 -0300 Subject: [PATCH 09/13] fix: GOOGLE_OAUTH_OVERRIDE should only be set on pizzas --- .github/workflows/build-react.yml | 7 ------- editor.planx.uk/src/pages/Login.tsx | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index d1df83ad4a..0c525fff44 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -13,12 +13,6 @@ jobs: name: Build React App runs-on: ubuntu-22.04 steps: - - name: test conditional env - run: | - echo "${{ true && 'true' || 'false' }}" - echo "${{ false && 'true' || 'false' }}" - echo "${{ true && 'something' || '' }}" - echo "${{ false && 'something' || '' }}" - uses: actions/checkout@v2 - uses: cardinalby/export-env-action@v2 with: @@ -56,7 +50,6 @@ jobs: REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 REACT_APP_HASURA_URL: https://hasura.${{ inputs.target }}/v1/graphql REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.target }} - # TODO: this shouldn't be set for staging # needed because there's no API to change google's allowed OAuth URLs REACT_APP_GOOGLE_OAUTH_OVERRIDE: "${{ inputs.environment == 'pizza' && 'https://api.editor.planx.dev' || '' }}" REACT_APP_ENV: ${{ inputs.environment }} diff --git a/editor.planx.uk/src/pages/Login.tsx b/editor.planx.uk/src/pages/Login.tsx index cc5fd468a4..4d27da438e 100644 --- a/editor.planx.uk/src/pages/Login.tsx +++ b/editor.planx.uk/src/pages/Login.tsx @@ -4,7 +4,7 @@ const Login: React.FC = () => { return ( From f65876a507ab97ce7e026620cf7f31fe871ef4af Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Tue, 28 Feb 2023 12:38:12 -0300 Subject: [PATCH 10/13] refact: DRY production react build --- .github/workflows/build-react.yml | 2 +- .github/workflows/push-main.yml | 1 - .github/workflows/push-production.yml | 59 +++------------------------ 3 files changed, 7 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index 0c525fff44..89c5ebaa8c 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -47,12 +47,12 @@ jobs: REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} REACT_APP_API_URL: https://api.${{ inputs.target }} + REACT_APP_ENV: ${{ inputs.environment }} REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 REACT_APP_HASURA_URL: https://hasura.${{ inputs.target }}/v1/graphql REACT_APP_SHAREDB_URL: wss://sharedb.${{ inputs.target }} # needed because there's no API to change google's allowed OAuth URLs REACT_APP_GOOGLE_OAUTH_OVERRIDE: "${{ inputs.environment == 'pizza' && 'https://api.editor.planx.dev' || '' }}" - REACT_APP_ENV: ${{ inputs.environment }} working-directory: ${{ env.EDITOR_DIRECTORY }} - name: Upload Build Artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index 92c7f7df8e..75ff9db579 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -17,7 +17,6 @@ jobs: build_react: name: Build React App needs: [changes] - if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" uses: ./.github/workflows/build-react.yml with: target: editor.planx.dev diff --git a/.github/workflows/push-production.yml b/.github/workflows/push-production.yml index 4d439f180c..264dbda4e2 100644 --- a/.github/workflows/push-production.yml +++ b/.github/workflows/push-production.yml @@ -15,59 +15,12 @@ env: jobs: build_react: - name: Test and Build - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - # https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#using-the-cache-action - - name: NPM cache - uses: actions/cache@v2 - env: - cache-name: cache-npm - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: PNPM cache - uses: actions/cache@v2 - env: - cache-name: cache-pnpm - with: - # pnpm cache files are stored in `~/.local/share/pnpm/store` on Linux - path: ~/.local/share/pnpm/store - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - run: npm install -g pnpm@${{ env.PNPM_VERSION }} - - run: pnpm distribute ../editor.planx.uk - working-directory: core - - run: pnpm install --frozen-lockfile - working-directory: editor.planx.uk - - run: pnpm build - working-directory: editor.planx.uk - env: - REACT_APP_API_URL: https://api.editor.planx.uk - REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1 - REACT_APP_HASURA_URL: https://hasura.editor.planx.uk/v1/graphql - REACT_APP_SHAREDB_URL: wss://sharedb.editor.planx.uk - REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }} - REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }} - REACT_APP_ENV: production - - name: Upload Build Artifact - uses: actions/upload-artifact@v2 - with: - name: build - path: ./editor.planx.uk/build - if-no-files-found: error + name: Build React App + needs: [changes] + uses: ./.github/workflows/build-react.yml + with: + target: editor.planx.uk + environment: production preview: name: Pulumi Up From 9da0fb6567fa5e178c778604859b343eba356ea5 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Tue, 28 Feb 2023 12:40:31 -0300 Subject: [PATCH 11/13] chore: simplify naming --- .github/workflows/build-react.yml | 2 +- .github/workflows/pull-request.yml | 2 +- .github/workflows/push-main.yml | 2 +- .github/workflows/push-production.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index 89c5ebaa8c..6350fa108b 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -10,7 +10,7 @@ on: jobs: build_react: - name: Build React App + name: Build runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d6911faeba..c9ddc84a51 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -170,7 +170,7 @@ jobs: working-directory: ${{ env.EDITOR_DIRECTORY }} build_react_app: - name: Build React App + name: React App needs: [changes] if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" uses: ./.github/workflows/build-react.yml diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index 75ff9db579..28d505615a 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -15,7 +15,7 @@ env: jobs: build_react: - name: Build React App + name: React App needs: [changes] uses: ./.github/workflows/build-react.yml with: diff --git a/.github/workflows/push-production.yml b/.github/workflows/push-production.yml index 264dbda4e2..d97e21cc41 100644 --- a/.github/workflows/push-production.yml +++ b/.github/workflows/push-production.yml @@ -15,7 +15,7 @@ env: jobs: build_react: - name: Build React App + name: React App needs: [changes] uses: ./.github/workflows/build-react.yml with: From f976fdb9e821d91fc10c08d566207b40a9085985 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Tue, 28 Feb 2023 13:06:21 -0300 Subject: [PATCH 12/13] fix: cache key --- .github/workflows/build-react.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml index 6350fa108b..4d3cd51f2a 100644 --- a/.github/workflows/build-react.yml +++ b/.github/workflows/build-react.yml @@ -24,7 +24,7 @@ jobs: uses: actions/cache@v3 with: path: ./${{ env.EDITOR_DIRECTORY }}/build - key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }}-${{ inputs.target }} + key: ${{ runner.os }}-${{ hashFiles('editor.planx.uk/**') }}-${{ inputs.environment }} - uses: pnpm/action-setup@v2.2.2 if: steps.cache-react-build-assets.outputs.cache-hit != 'true' with: From bf19af1f144a617f13a3e6463cd6fc83989d01c8 Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Tue, 28 Feb 2023 16:32:38 -0300 Subject: [PATCH 13/13] chore: remove comment --- .github/workflows/pull-request.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c9ddc84a51..e98fffa0da 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -175,9 +175,6 @@ jobs: if: "${{ !contains(needs.changes.outputs.commit, '[skip pizza]') }}" uses: ./.github/workflows/build-react.yml with: - # TODO: replace `planx.pizza` for `${{ env.DOMAIN }}` - # although it's not possible to use env variables in `with` section - # you might be able to use `env` section to set `DOMAIN` variable target: "${{ github.event.number }}.planx.pizza" environment: "pizza"