diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e818e7b..81ccd87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,11 +10,29 @@ concurrency: jobs: define_shared_variables: + runs-on: ubuntu-latest + env: + NODE_VERSION: 16.15.1 + + steps: + - name: Export variables to JSON + id: varsStep + uses: actions/github-script@v6 + with: + script: core.setOutput('value', ${{ toJson(env) }}) + + outputs: + vars: ${{ steps.varsStep.outputs.value }} + + share_variables: uses: ./.github/workflows/define-shared-variables.yml + needs: define_shared_variables + with: + shared-variables: ${{ needs.define_shared_variables.outputs.vars }} install_dependencies: uses: ./.github/workflows/install-dependencies.yml - needs: define_shared_variables + needs: share_variables build_lib: uses: ./.github/workflows/base-build.yml diff --git a/.github/workflows/define-shared-variables.yml b/.github/workflows/define-shared-variables.yml index 30a4fe0..951ec36 100644 --- a/.github/workflows/define-shared-variables.yml +++ b/.github/workflows/define-shared-variables.yml @@ -22,7 +22,8 @@ jobs: uses: actions/github-script@v6 with: script: | - const sharedVariablesObject = '${{ inputs.shared-variables }}' || {}; + const envVarsFromInputs = `${{ inputs.shared-variables }}`; + const sharedVariablesObject = envVarsFromInputs ? JSON.parse(envVarsFromInputs) : {}; function exportVariable(name, value) { sharedVariablesObject[name] = value; @@ -58,7 +59,6 @@ jobs: id: sharedVarsStep uses: actions/github-script@v6 env: - NODE_VERSION: 16.15.1 DEPENDENCIES_CACHE_KEY: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('**/package-lock.json') }} DEPENDENCIES_RESTORE_KEY: '' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 268e0f8..8b1b70f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,11 +10,29 @@ concurrency: jobs: define_shared_variables: + runs-on: ubuntu-latest + env: + NODE_VERSION: 16.15.1 + + steps: + - name: Export variables to JSON + id: varsStep + uses: actions/github-script@v6 + with: + script: core.setOutput('value', ${{ toJson(env) }}) + + outputs: + vars: ${{ steps.varsStep.outputs.value }} + + share_variables: uses: ./.github/workflows/define-shared-variables.yml + needs: define_shared_variables + with: + shared-variables: ${{ needs.define_shared_variables.outputs.vars }} install_dependencies: uses: ./.github/workflows/install-dependencies.yml - needs: define_shared_variables + needs: share_variables build_lib: uses: ./.github/workflows/base-build.yml