From 0d3135f4e4f65b828513f3df5ed77c832c55bf97 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 17 Nov 2023 12:07:42 -0600 Subject: [PATCH] refactor: move GitHub secrets to GitHub Actions inputs --- .github/actions/tests/python/action.yml | 54 +++++++++------------ .github/workflows/pullRequestController.yml | 4 ++ .github/workflows/runTests.yml | 4 ++ 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/actions/tests/python/action.yml b/.github/actions/tests/python/action.yml index b4500e03..acf895e4 100644 --- a/.github/actions/tests/python/action.yml +++ b/.github/actions/tests/python/action.yml @@ -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' @@ -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 @@ -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 diff --git a/.github/workflows/pullRequestController.yml b/.github/workflows/pullRequestController.yml index e5f87138..6361cdfe 100644 --- a/.github/workflows/pullRequestController.yml +++ b/.github/workflows/pullRequestController.yml @@ -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 diff --git a/.github/workflows/runTests.yml b/.github/workflows/runTests.yml index 3f121e9d..52324192 100644 --- a/.github/workflows/runTests.yml +++ b/.github/workflows/runTests.yml @@ -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