Bump virtualenv from 20.34.0 to 20.36.1 (#94) #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Deploy Functions to CDF project using OIDC | |
| on: | |
| push: | |
| branches: [master] | |
| jobs: | |
| generate-matrix: | |
| uses: "./.github/workflows/generate-matrix.yaml" | |
| with: | |
| deploy_folders: "example_function1, example_function2" | |
| trigger_deploy_all_folders: "common" | |
| deploy: | |
| needs: generate-matrix | |
| name: Deploy to Cognite Functions | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| function: ${{ fromJson(needs.generate-matrix.outputs.folders) }} | |
| # Add environments to deploy to. | |
| # Each environment should have a corresponding github environment with secrets. | |
| environment: | |
| - test | |
| environment: ${{ matrix.environment }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| if: ${{ contains(needs.generate-matrix.outputs.deploy_folders, matrix.function) }} | |
| with: # we deploy based on a diff vs. prev commit, thus we need history: | |
| fetch-depth: 0 | |
| - name: Extract branch name | |
| if: ${{ contains(needs.generate-matrix.outputs.deploy_folders, matrix.function) }} | |
| shell: bash | |
| run: echo branch=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT | |
| id: extract_branch | |
| - name: Install yq | |
| if: ${{ contains(needs.generate-matrix.outputs.deploy_folders, matrix.function) }} | |
| run: | | |
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.27.5/yq_linux_amd64 | |
| sudo chmod +x /usr/local/bin/yq | |
| - name: Extract config file parameters | |
| if: ${{ contains(needs.generate-matrix.outputs.deploy_folders, matrix.function) }} | |
| shell: bash | |
| run: | | |
| CONFIG_FILES=("${{ matrix.function }}/function_config.yaml ${{ matrix.function }}/function_config_${{ matrix.environment }}.yaml") | |
| echo "Config files to use are ${CONFIG_FILES[@]}" | |
| for FILE in ${CONFIG_FILES[@]} | |
| do | |
| echo $FILE | |
| if [ ! -f $FILE ]; then | |
| echo "Config: $FILE not supplied!" | |
| else | |
| ALLKEYS=$(yq -o=tsv "keys" $FILE) | |
| for CONFIGURATION in $ALLKEYS | |
| do | |
| VALUE=$(yq -o=json -I=0 ".$CONFIGURATION" $FILE | sed -e 's/^"//' -e 's/"$//') | |
| echo $CONFIGURATION=$VALUE >> $GITHUB_OUTPUT | |
| done | |
| fi | |
| done | |
| id: extract_params | |
| - name: Extra secrets | |
| if: ${{ contains(needs.generate-matrix.outputs.deploy_folders, matrix.function) }} | |
| shell: bash | |
| # Secret name should be EXTRA_SECRETS_{function name} (if applicable) | |
| run: | | |
| echo "extra_secrets_name=EXTRA_SECRETS_${{ matrix.function }}" >> $GITHUB_OUTPUT | |
| id: extract_secrets | |
| - name: Deploy and schedule ${{matrix.function }} | |
| if: ${{ contains(needs.generate-matrix.outputs.deploy_folders, matrix.function) }} | |
| uses: cognitedata/function-action-oidc@v1 | |
| with: | |
| # Parameters you may likely hardcode here directly. | |
| # - If you need to specify them individually, change them into...: | |
| # foo_bar: ${{ steps.extract_params.outputs.foo_bar }} | |
| deployment_client_id: 5f18d04a-2d2a-41a2-aa15-bd62a149cd14 | |
| deployment_tenant_id: 0d75f6b8-c6b9-4e84-baca-503e08aa7e4a | |
| schedules_client_id: 9347b37d-e94f-44d5-a69d-5867f55d7f6e | |
| schedules_tenant_id: 0d75f6b8-c6b9-4e84-baca-503e08aa7e4a | |
| cdf_project: forge-sandbox # or my-company, my-organisation-prod etc. | |
| cdf_cluster: greenfield # or api, westeurope-1, etc. | |
| runtime: py39 | |
| await_deployment_success: true # set to false to skip waiting for deployments entirely | |
| # Parameters we can read/extract automatically: | |
| function_folder: ${{ matrix.function }} | |
| function_external_id: ${{ matrix.function }}-${{ steps.extract_branch.outputs.branch }} | |
| schedule_file: schedules/${{ matrix.environment }}.yaml | |
| # Parameters we get from Github secret storage: | |
| deployment_client_secret: ${{secrets.DEPLOYMENT_CLIENT_SECRET }} | |
| schedules_client_secret: ${{ secrets.SCHEDULES_CLIENT_SECRET }} | |
| function_secrets: ${{ secrets[steps.extract_secrets.outputs.extra_secrets_name] }} | |
| # Individual parameters per function we read from: | |
| # - function_config.yaml | |
| # - function_config_[environment].yaml | |
| data_set_id: ${{ steps.extract_params.outputs.data_set_id }} | |
| common_folder: ${{ steps.extract_params.outputs.common_folder }} | |
| function_deploy_timeout: ${{ steps.extract_params.outputs.function_deploy_timeout }} | |
| post_deploy_cleanup: ${{ steps.extract_params.outputs.post_deploy_cleanup }} | |
| description: ${{ steps.extract_params.outputs.description }} | |
| owner: ${{ steps.extract_params.outputs.owner }} | |
| env_vars: ${{ steps.extract_params.outputs.env_vars }} | |
| metadata: ${{ steps.extract_params.outputs.metadata }} | |
| # Individual parameters seldom needed: | |
| index_url: ${{ steps.extract_params.outputs.index_url }} | |
| extra_index_urls: ${{ steps.extract_params.outputs.extra_index_urls }} |