From acc782fb44ebf58a50d84e629afe7532b392c3de Mon Sep 17 00:00:00 2001 From: Gunar Gessner Date: Mon, 27 Feb 2023 22:14:02 -0300 Subject: [PATCH] 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..21a5e0d4d1 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: '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