Skip to content

Commit

Permalink
refactor: move GitHub secrets to GitHub Actions inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Nov 17, 2023
1 parent 5d72df8 commit 0d3135f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
54 changes: 22 additions & 32 deletions .github/actions/tests/python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ inputs:
description: 'The version of Python to use, such as 3.11.0'
required: true
type: string
openai-api-organization:
description: 'The OpenAI API organization'
required: true
type: string
openai-api-key:
description: 'The OpenAI API key'
required: true
type: string
pinecone-api-key:
description: 'The Pinecone API key'
required: true
type: string
pinecone-environment:
description: 'The Pinecone environment'
required: true
type: string

env:
REQUIREMENTS_PATH: 'api/terraform/python/layer_genai/requirements.txt'

Expand All @@ -20,38 +37,6 @@ runs:
id: checkout
uses: actions/checkout@v4

- name: Verify OPENAI_API_ORGANIZATION
shell: bash
run: |
if [[ -z "${{ secrets.OPENAI_API_ORGANIZATION }}" ]]; then
echo "OPENAI_API_ORGANIZATION is not set" >&2
exit 1
fi
- name: Verify OPENAI_API_KEY
shell: bash
run: |
if [[ -z "${{ secrets.OPENAI_API_KEY }}" ]]; then
echo "OPENAI_API_KEY is not set" >&2
exit 1
fi
- name: Verify PINECONE_API_KEY
shell: bash
run: |
if [[ -z "${{ secrets.PINECONE_API_KEY }}" ]]; then
echo "PINECONE_API_KEY is not set" >&2
exit 1
fi
- name: Verify PINECONE_ENVIRONMENT
shell: bash
run: |
if [[ -z "${{ secrets.PINECONE_ENVIRONMENT }}" ]]; then
echo "PINECONE_ENVIRONMENT is not set" >&2
exit 1
fi
- name: Check for openai in requirements
run: |
if ! grep -q "openai" ./requirements.txt; then
Expand Down Expand Up @@ -101,6 +86,11 @@ runs:
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> ./.env
echo "PINECONE_API_KEY=${{ secrets.PINECONE_API_KEY }}" >> ./.env
echo "PINECONE_ENVIRONMENT=${{ secrets.PINECONE_ENVIRONMENT }}" >> ./.env
env:
OPENAI_API_ORGANIZATION: ${{ inputs.openai-api-organization }}
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
PINECONE_API_KEY: ${{ inputs.pinecone-api-key }}
PINECONE_ENVIRONMENT: ${{ inputs.pinecone-environment }}

- name: Test lambda_openai_v2
shell: bash
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pullRequestController.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ jobs:
uses: ./.github/actions/tests/python
with:
python-version: "${{ env.python-version}}"
openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}"
openai-api-key: "${{ secrets.OPENAI_API_KEY }}"
pinecone-api-key: "${{ secrets.PINECONE_API_KEY }}"
pinecone-environment: "${{ secrets.PINECONE_ENVIRONMENT }}"

terraform_tests:
needs: check_for_pending_release
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
uses: ./.github/actions/tests/python
with:
python-version: "${{ env.python-version}}"
openai-api-organization: "${{ secrets.OPENAI_API_ORGANIZATION }}"
openai-api-key: "${{ secrets.OPENAI_API_KEY }}"
pinecone-api-key: "${{ secrets.PINECONE_API_KEY }}"
pinecone-environment: "${{ secrets.PINECONE_ENVIRONMENT }}"

- name: Run Terraform tests
uses: ./.github/actions/tests/reactjs
Expand Down

0 comments on commit 0d3135f

Please sign in to comment.