feat: add ability to set PYTHON_VERSION via variables #6
Workflow file for this run
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: build-product | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs_on: | ||
| type: string | ||
| required: false | ||
| default: "ubuntu-22.04" | ||
| secrets: | ||
| DATAVISYN_BOT_REPO_TOKEN: | ||
| required: false | ||
| DV_BOT_USER: | ||
| required: false | ||
| NODE_VERSION: | ||
| required: false | ||
| PYTHON_VERSION: | ||
| required: false | ||
| GITLAB_TOKEN: | ||
| required: false | ||
| GITLAB_HOST: | ||
| required: false | ||
| CHECKOUT_TOKEN: | ||
| required: false | ||
| description: Token to pass to the build-single job. Use this to allow the checkout actions to access private repositories. | ||
| concurrency: | ||
| group: "${{ github.workflow }}-${{ github.ref || github.head_ref }}" | ||
| cancel-in-progress: true | ||
| env: | ||
| TIME_ZONE: "Europe/Vienna" | ||
| NODE_VERSION: "20.9" | ||
| PYTHON_VERSION: ${{ vars.PYTHON_VERSION || "3.10" }} | ||
| WORKFLOW_BRANCH: "main" | ||
| PYTHON_BASE_IMAGE: "python:3.10.18-slim-bullseye" | ||
| DATAVISYN_PYTHON_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/python:main" | ||
| DATAVISYN_NGINX_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/nginx:main" | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| jobs: | ||
| prepare-build: | ||
| outputs: | ||
| app: ${{ steps.get-parameters.outputs.app }} | ||
| develop: ${{ steps.get-parameters.outputs.develop }} | ||
| sub_app: ${{ steps.get-parameters.outputs.sub_app }} | ||
| trigger_automatic_deployment: ${{ steps.get-parameters.outputs.trigger_automatic_deployment }} | ||
| customers: ${{ steps.get-parameters.outputs.customers }} | ||
| image_tag1: ${{ steps.get-parameters.outputs.image_tag1 }} | ||
| image_tag2: ${{ steps.get-parameters.outputs.image_tag2 }} | ||
| build_time: ${{ steps.get-parameters.outputs.build_time }} | ||
| repo: ${{ steps.get-parameters.outputs.repo }} | ||
| branch: ${{ steps.get-parameters.outputs.branch }} | ||
| components: ${{ steps.get-parameters.outputs.components }} | ||
| ecr_repos: ${{ steps.get-parameters.outputs.ecr_repos }} | ||
| ecr_repository_keys: ${{ steps.get-parameters.outputs.ecr_repository_keys }} | ||
| create_workspace: ${{ steps.get-parameters.outputs.create_workspace }} | ||
| stage: ${{ steps.get-parameters.outputs.stage }} | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| # checkout specific repository | ||
| - uses: actions/checkout@v4 | ||
| # checkout this workflow repository to get actions | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| repository: datavisyn/github-workflows | ||
| ref: ${{ env.WORKFLOW_BRANCH }} | ||
| path: ./tmp/github-workflows | ||
| - name: lint dockerfiles | ||
| id: lint-docker | ||
| uses: ./tmp/github-workflows/.github/actions/lint-docker | ||
| with: | ||
| config: .github/linters/.hadolint.yaml | ||
| recursive: true | ||
| - name: show dockerfile lint error | ||
| if: ${{ failure() && steps.lint-docker.outcome == 'failure' }} | ||
| run: | | ||
| echo ${{ steps.lint-docker.outcome }} | ||
| echo -e "#### Docker Lint Result: ${{ steps.lint-docker.outputs.results }}" | ||
| - name: lint github action files | ||
| id: lint-ga | ||
| uses: ./tmp/github-workflows/.github/actions/lint-github-actions | ||
| - uses: ./tmp/github-workflows/.github/actions/get-product-parameters | ||
| id: get-parameters | ||
| with: | ||
| branch_name: ${{ github.ref_name }} | ||
| time_zone: ${{ env.TIME_ZONE }} | ||
| build-single: | ||
| needs: prepare-build | ||
| if: ${{ needs.prepare-build.outputs.create_workspace != 'true' && needs.prepare-build.outputs.components != '[]' && needs.prepare-build.outputs.components != ''}} | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| component: ${{fromJson(needs.prepare-build.outputs.components)}} | ||
| uses: datavisyn/github-workflows/.github/workflows/build-single-product-part.yml@main | ||
| with: | ||
| component: ${{ matrix.component }} | ||
| image_tag1: ${{ needs.prepare-build.outputs.image_tag1 }} | ||
| image_tag2: ${{ needs.prepare-build.outputs.image_tag2 }} | ||
| build_time: ${{ needs.prepare-build.outputs.build_time }} | ||
| stage: ${{ needs.prepare-build.outputs.stage }} | ||
| runs_on: ${{ inputs.runs_on }} | ||
| secrets: inherit | ||
| build-workspace: | ||
| needs: prepare-build | ||
| if: ${{ needs.prepare-build.outputs.create_workspace == 'true' && needs.prepare-build.outputs.components != '[]' && needs.prepare-build.outputs.components != ''}} | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| component: ${{fromJson(needs.prepare-build.outputs.components)}} | ||
| uses: datavisyn/github-workflows/.github/workflows/build-workspace-product-part.yml@main | ||
| with: | ||
| component: ${{ matrix.component }} | ||
| image_tag1: ${{ needs.prepare-build.outputs.image_tag1 }} | ||
| image_tag2: ${{ needs.prepare-build.outputs.image_tag2 }} | ||
| build_time: ${{ needs.prepare-build.outputs.build_time }} | ||
| stage: ${{ needs.prepare-build.outputs.stage }} | ||
| secrets: inherit | ||
| post-build: | ||
| needs: [prepare-build, build-single, build-workspace] | ||
| if: ${{ always() && (needs.build-single.result == 'success' || needs.build-single.result == 'skipped') && (needs.build-workspace.result == 'success' || needs.build-workspace.result == 'skipped') && !(needs.build-workspace.result == 'skipped' && needs.build-single.result == 'skipped')}} | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| repository: datavisyn/github-workflows | ||
| ref: ${{ env.WORKFLOW_BRANCH }} | ||
| path: ./tmp/github-workflows | ||
| - name: retag images | ||
| uses: ./tmp/github-workflows/.github/actions/retag-image | ||
| with: | ||
| aws_role: ${{ vars.DV_AWS_ECR_ROLE }} | ||
| aws_region: ${{ vars.DV_AWS_REGION }} | ||
| ecr_repositories: ${{ needs.prepare-build.outputs.ecr_repos }} | ||
| current_image_tag: ${{ needs.prepare-build.outputs.image_tag1 }} | ||
| additional_image_tag: ${{ needs.prepare-build.outputs.image_tag2 }} | ||
| deploy: | ||
| needs: [prepare-build, post-build] | ||
| # Add always() as otherwise the job is being skipped: https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions | ||
| if: ${{ always() && needs.post-build.result == 'success' && fromJSON(needs.prepare-build.outputs.trigger_automatic_deployment) }} | ||
| runs-on: ubuntu-22.04 | ||
| strategy: | ||
| matrix: | ||
| customer: ${{ fromJSON(needs.prepare-build.outputs.customers) }} | ||
| steps: | ||
| - name: determine stage to be deployed to | ||
| id: get-parameters | ||
| run: | | ||
| # Try to split the customer from the format customer:stage | ||
| customer="$(echo "$CUSTOMER_FULL" | cut -d ":" -s -f 1)" | ||
| stage="$(echo "$CUSTOMER_FULL" | cut -d ":" -s -f 2)" | ||
| # If nothing is found, we assume we just got the customer | ||
| if [ -z "$customer" ]; then | ||
| customer="$CUSTOMER_FULL" | ||
| fi | ||
| # And will deploy to develop if no stage is defined | ||
| if [ -z "$stage" ]; then | ||
| echo "customer $CUSTOMER_FULL does not include stage, using develop instead" | ||
| stage="develop" | ||
| fi | ||
| echo "customer=$customer" >> "$GITHUB_OUTPUT" | ||
| echo "stage=$stage" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| CUSTOMER_FULL: ${{ matrix.customer }} | ||
| shell: bash | ||
| - name: trigger deployment | ||
| uses: datavisyn/github-action-trigger-workflow@v1 | ||
| with: | ||
| owner: "datavisyn" | ||
| repo: "infrastructure-k8s" | ||
| github_token: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }} | ||
| workflow_file_name: "deploy-app.yml" | ||
| ref: ${{ env.WORKFLOW_BRANCH }} | ||
| github_user: ${{ secrets.DV_BOT_USER }} | ||
| client_payload: '{ "app": "${{ needs.prepare-build.outputs.app }}", "customer": "${{ steps.get-parameters.outputs.customer }}", "stage": "${{ steps.get-parameters.outputs.stage }}", "sub_app": "${{ needs.prepare-build.outputs.sub_app }}", "branch": "${{ needs.prepare-build.outputs.image_tag2 }}", "image_tag": "${{ needs.prepare-build.outputs.image_tag1 }}" }' | ||