Skip to content

Commit

Permalink
testing env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
M3GH4NN committed Mar 15, 2024
1 parent ad1d740 commit cf32899
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@ on:
version:
required: false
type: string
secrets:
PYPI_API_TOKEN:
required: false
TEST_PYPI_API_TOKEN:
required: false
AZURE_CLIENT_ID:
required: false
AZURE_TENANT_ID:
required: false
AZURE_CLIENT_SECRET:
required: false
secrets: ${{ toJson(secrets) }}


jobs:
Expand Down Expand Up @@ -54,13 +44,11 @@ jobs:
name: Test
needs:
- pre-commit
uses: salt-extensions/central-artifacts/.github/workflows/test-action.yml@main
# uses: salt-extensions/central-artifacts/.github/workflows/test-action.yml@main
uses: M3GH4NN/central-artifacts/.github/workflows/test-action.yml@credentials
with:
setup-vault: ${{ inputs.setup-vault }}
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
secrets: ${{ toJson(secrets) }}

docs:
name: Docs
Expand Down Expand Up @@ -137,4 +125,4 @@ jobs:
run:
echo "All workflows finished"

####
####
29 changes: 29 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
required: false
type: boolean
default: false
secrets:
env_vars:
required: true

jobs:
Linux:
Expand All @@ -29,6 +32,22 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Decode credentials as env vars
env:
env_vars: ${{ secrets.env_vars }}
run: |
for i in $env_vars; do
i=$(echo $i | sed 's/=.*//g')=$(echo ${i#*=} | base64 -di | base64 -di)
echo ::add-mask::${i#*=}
printf '%s\n' "$i" >> $GITHUB_ENV
done
- name: Validate credentials
run: |
# Secrets are now available as masked env vars
echo $CREDENTIAL1
echo $CREDENTIAL2
echo $CREDENTIAL3
- name: Setup Vault
if: ${{ inputs.setup-vault }}
Expand All @@ -52,11 +71,21 @@ jobs:
run: |
nox --force-color -e tests-3 --install-only
- name: Test env vars
env:
env_vars: ${{ toJson(secrets.env_vars )}}
run: |
for secret in $(echo $env_vars | jq -r "to_entries|map(\"\(.key)=\(.value|@base64)\")|.[]"); do
key=$(echo $secret | cut -d "=" -f 1)
value=$(echo $secret | cut -d "=" -f 2 | base64 -d)
echo "export $key=\"$value\"" >> $GITHUB_ENV
done
- name: Test
env:
SALT_REQUIREMENT: salt==${{ matrix.salt-version }}
SKIP_REQUIREMENTS_INSTALL: YES
run: |
echo $AZURE_CLIENT_ID
nox --force-color -e tests-3 -- -vv tests/
- name: Create CodeCov Flags
Expand Down

0 comments on commit cf32899

Please sign in to comment.