Skip to content

Commit

Permalink
Fix: Pass secrets and vars thru env
Browse files Browse the repository at this point in the history
Passing secrets through nested composable workflows
may potentially by reseting the values causing unmarshall
errors.

Signed-off-by: Anil Belur <[email protected]>
  • Loading branch information
askb committed Nov 20, 2023
1 parent f2082b3 commit 7290650
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/compose-packer-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ on:
description: "Gerrit refspec of change"
required: true
type: string
ENV_VARS:
# yamllint disable-line rule:line-length
description: "Pass GitHub variables to be exported as environment variables via `toJSON(vars)` or specific variables encoded in JSON format"
required: false
default: "{}"
type: string
ENV_SECRETS:
# yamllint disable-line rule:line-length
description: "Pass GitHub secrets to be exported as environment variables via `toJSON(secrets)` or specific secrets encoded in JSON format"
required: false
default: "{}"
type: string
secrets:
CLOUDS_ENV_B64:
description: "Packer cloud environment credentials"
Expand Down Expand Up @@ -87,13 +99,23 @@ jobs:
id: setup
with:
version: ${{ env.PACKER_VERSION }}
- name: Export env variables
if: steps.changes.outputs.src == 'true'
uses: infovista-opensource/[email protected]
with:
secrets: ${{ inputs.ENV_VARS }}
- name: Export env secrets
if: steps.changes.outputs.src == 'true'
uses: infovista-opensource/[email protected]
with:
secrets: ${{ inputs.ENV_SECRETS }}
- name: Create cloud-env file required for packer
id: create-cloud-env-file
if: steps.changes.outputs.src == 'true'
shell: bash
# yamllint disable rule:line-length
run: |
echo "${{ secrets.CLOUDS_ENV_B64 }}" | base64 --decode > "${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl"
echo "${{ env.CLOUDS_ENV_B64 }}" | base64 --decode > "${GITHUB_WORKSPACE}/cloud-env.pkrvars.hcl"
# yamllint enable rule:line-length
- name: Create cloud.yaml file for openstack client
id: create-cloud-yaml-file
Expand All @@ -102,7 +124,7 @@ jobs:
# yamllint disable rule:line-length
run: |
mkdir -p "$HOME/.config/openstack"
echo "${{ secrets.CLOUDS_YAML_B64 }}" | base64 --decode > "$HOME/.config/openstack/clouds.yaml"
echo "${{ env.CLOUDS_YAML_B64 }}" | base64 --decode > "$HOME/.config/openstack/clouds.yaml"
# yamllint enable rule:line-length
- name: Setup Python
if: steps.changes.outputs.src == 'true'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/composed-ci-management-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ jobs:
GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
ENV_VARS: ${{ inputs.ENV_VARS }}
ENV_SECRETS: ${{ inputs.ENV_SECRETS }}
secrets:
CLOUDS_ENV_B64: ${{ secrets.CLOUDS_ENV_B64 }}
CLOUDS_YAML_B64: ${{ secrets.CLOUDS_ENV_B64 }}
Expand Down

0 comments on commit 7290650

Please sign in to comment.