Merge pull request #878 from Dynatrace/adjust-dockert-restart-retries #208
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
| # This GitHub Actions workflow is designed to validate pull requests (PRs) with demo use cases. | |
| # | |
| # Workflow Name: Validate PRs with demo use cases | |
| # | |
| # Triggers: | |
| # - on push to the 'dev' branch | |
| # - manual trigger via workflow_dispatch with the following inputs: | |
| # - use_cases: Comma-separated list of use cases to run (default: '["demo_all"]') | |
| # - providers: Comma-separated list of providers to run (default: '["gcloud"]') | |
| # - destroy_resources: Boolean to enable resource destruction (default: true) | |
| # - use_case_validation_tests_enabled: Boolean to enable use case validation tests (default: false) | |
| # - custom_domain: Custom domain name for validation (default: "") | |
| # - dt_tenant: Dynatrace Tenant (default: "") | |
| # - dt_url_gen3: Dynatrace Environment URL Gen3 (default: "") | |
| # | |
| # Environment Variables: | |
| # - DEFAULT_USE_CASES: Default use cases to run (default: '["demo_all"]') | |
| # - DEFAULT_PROVIDERS: Default providers to run (default: '["gcloud"]') | |
| # - DESTROY_RESOURCES: Default value for resource destruction (default: true) | |
| # - USE_CASE_VALIDATION_TESTS_ENABLED: Default value for use case validation tests (default: false) | |
| # - DEFAULT_CUSTOM_DOMAIN: Default custom domain name (default: "") | |
| # - DT_TENANT: Dynatrace Tenant from GitHub variables | |
| # - DT_URL_GEN3: Dynatrace Environment URL Gen3 from GitHub variables | |
| # - DT_API_TOKEN: Dynatrace API Token from GitHub secrets | |
| # | |
| # Jobs: | |
| # 1. set_env_vars: | |
| # - Runs on a spot instance | |
| # - Sets environment variables based on the trigger event (push or workflow_dispatch) | |
| # - Outputs the set environment variables for use in subsequent jobs | |
| # | |
| # 2. test_demo_usecases: | |
| # - Needs the set_env_vars job to complete | |
| # - Uses the validation.yaml workflow to test demo use cases | |
| # - Passes the environment variables and secrets to the validation workflow | |
| name: Validate PRs with demo use cases | |
| on: | |
| push: | |
| branches: | |
| - dev # Trigger after PR is merged to the dev branch | |
| workflow_dispatch: # Allows manual triggering of the workflow | |
| inputs: | |
| use_cases: | |
| description: 'Enter the use cases to run (comma-separated). Example: ["demo_ar_workflows_gitlab","demo_ar_workflows_ansible"]' | |
| required: true | |
| default: '["demo_all"]' | |
| type: string | |
| providers: | |
| description: 'Select the providers to run (comma-separated). Example: ["gcloud","aws"]. For GCP, provide the GCP_CREDENTIALS_JSON in the Github repository secrets.' | |
| required: true | |
| default: '["gcloud"]' | |
| type: string | |
| destroy_resources: | |
| description: 'Select to enable resource destruction' | |
| required: true | |
| default: true | |
| type: boolean | |
| use_case_validation_tests_enabled: | |
| description: 'Select to enable use case validation tests' | |
| required: false | |
| default: false | |
| type: boolean | |
| custom_domain: | |
| description: "Custom Domain Name. Example: demo.ace-innovation.info. Keep empty for temporary validations." | |
| required: false | |
| default: "" | |
| type: string | |
| ace_box_name_prefix: | |
| description: "Ace-Box Name Prefix to identify the resources created by this workflow. Example: demo-ace-box." | |
| required: false | |
| default: "ace-box-gh-pr-validate" | |
| type: string | |
| # optional params for manual run | |
| dt_tenant: | |
| description: "Dynatrace Tenant. Keep empty to use the default tenant configured in the Github variables. For API Token, modify the DT_API_TOKEN secret in the Github repository settings." | |
| required: false | |
| default: "" | |
| type: string | |
| dt_url_gen3: | |
| description: "Dynatrace Environment URL Gen3. Keep empty to use the default tenant configured in the Github variables. For OAuth, modify the DT_OAUTH_CLIENT_ID and DT_OAUTH_CLIENT_SECRET secrets in the Github repository settings." | |
| required: false | |
| default: "" | |
| type: string | |
| env: | |
| DEFAULT_USE_CASES: '[\"demo_all\"]' | |
| DEFAULT_PROVIDERS: '[\"gcloud\"]' | |
| DESTROY_RESOURCES: true | |
| USE_CASE_VALIDATION_TESTS_ENABLED: true | |
| DEFAULT_CUSTOM_DOMAIN: "" | |
| DEFAULT_ACE_BOX_NAME_PREFIX: "ace-box-gh-pr-validate" | |
| DT_TENANT: ${{ vars.DT_TENANT }} | |
| DT_URL_GEN3: ${{ vars.DT_URL_GEN3 }} | |
| DT_API_TOKEN: ${{ secrets.DT_API_TOKEN }} | |
| jobs: | |
| set_env_vars: | |
| runs-on: spot | |
| outputs: | |
| use_cases: ${{ steps.set_outputs.outputs.use_cases }} | |
| providers: ${{ steps.set_outputs.outputs.providers }} | |
| destroy_resources: ${{ steps.set_outputs.outputs.destroy_resources }} | |
| use_case_validation_tests_enabled: ${{ steps.set_outputs.outputs.use_case_validation_tests_enabled }} | |
| custom_domain: ${{ steps.set_outputs.outputs.custom_domain }} | |
| ace_box_name_prefix: ${{ steps.set_outputs.outputs.ace_box_name_prefix }} | |
| dt_tenant: ${{ steps.set_outputs.outputs.dt_tenant }} | |
| dt_url_gen3: ${{ steps.set_outputs.outputs.dt_url_gen3 }} | |
| steps: | |
| - name: Set Environment Variables | |
| id: set_env | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "use_cases=$(echo '${{ github.event.inputs.use_cases }}' )" >> "$GITHUB_ENV" | |
| echo "providers=$(echo '${{ github.event.inputs.providers }}' )" >> "$GITHUB_ENV" | |
| echo "destroy_resources=$(echo '${{ github.event.inputs.destroy_resources }}' )" >> "$GITHUB_ENV" | |
| echo "use_case_validation_tests_enabled=$(echo ${{ github.event.inputs.use_case_validation_tests_enabled }} )" >> "$GITHUB_ENV" | |
| echo "custom_domain=$(echo '${{ github.event.inputs.custom_domain }}' )" >> "$GITHUB_ENV" | |
| echo "ace_box_name_prefix=$(echo '${{ github.event.inputs.ace_box_name_prefix }}' )" >> "$GITHUB_ENV" | |
| echo "dt_tenant=$(echo '${{ github.event.inputs.dt_tenant }}' )" >> "$GITHUB_ENV" | |
| echo "dt_url_gen3=$(echo '${{ github.event.inputs.dt_url_gen3 }}' )" >> "$GITHUB_ENV" | |
| else | |
| echo "use_cases=${{ env.DEFAULT_USE_CASES }}" >> "$GITHUB_ENV" | |
| echo "providers=${{ env.DEFAULT_PROVIDERS }}" >> "$GITHUB_ENV" | |
| echo "destroy_resources=${{ env.DESTROY_RESOURCES }}" >> "$GITHUB_ENV" | |
| echo "use_case_validation_tests_enabled=${{ env.USE_CASE_VALIDATION_TESTS_ENABLED }}" >> "$GITHUB_ENV" | |
| echo "custom_domain=${{ env.DEFAULT_CUSTOM_DOMAIN }}" >> "$GITHUB_ENV" | |
| echo "ace_box_name_prefix=${{ env.DEFAULT_ACE_BOX_NAME_PREFIX }}" >> "$GITHUB_ENV" | |
| echo "dt_tenant=${{ env.DT_TENANT }}" >> "$GITHUB_ENV" | |
| echo "dt_url_gen3=${{ env.DT_URL_GEN3 }}" >> "$GITHUB_ENV" | |
| fi | |
| - name: Convert use_case_validation_tests_enabled to Boolean | |
| run: | | |
| if [[ "${{ github.event.inputs.use_case_validation_tests_enabled }}" == "true" ]]; then | |
| echo "use_case_validation_tests_enabled=true" >> "$GITHUB_ENV" | |
| else | |
| echo "use_case_validation_tests_enabled=false" >> "$GITHUB_ENV" | |
| fi | |
| - name: Set Outputs | |
| id: set_outputs | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "use_cases=$(echo '${{ github.event.inputs.use_cases }}' )" >> "$GITHUB_OUTPUT" | |
| echo "providers=$(echo '${{ github.event.inputs.providers }}' )" >> "$GITHUB_OUTPUT" | |
| echo "destroy_resources=$(echo '${{ github.event.inputs.destroy_resources }}' )" >> "$GITHUB_OUTPUT" | |
| echo "use_case_validation_tests_enabled=$(echo '${{ github.event.inputs.use_case_validation_tests_enabled }}' )" >> "$GITHUB_OUTPUT" | |
| echo "custom_domain=$(echo '${{ github.event.inputs.custom_domain }}' )" >> "$GITHUB_OUTPUT" | |
| echo "ace_box_name_prefix=$(echo '${{ github.event.inputs.ace_box_name_prefix }}' )" >> "$GITHUB_OUTPUT" | |
| echo "dt_tenant=$(echo '${{ github.event.inputs.dt_tenant }}' )" >> "$GITHUB_OUTPUT" | |
| echo "dt_url_gen3=$(echo '${{ github.event.inputs.dt_url_gen3 }}' )" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "use_cases=${{ env.DEFAULT_USE_CASES }}" >> "$GITHUB_OUTPUT" | |
| echo "providers=${{ env.DEFAULT_PROVIDERS }}" >> "$GITHUB_OUTPUT" | |
| echo "destroy_resources=${{ env.DESTROY_RESOURCES }}" >> "$GITHUB_OUTPUT" | |
| echo "use_case_validation_tests_enabled=${{ env.USE_CASE_VALIDATION_TESTS_ENABLED }}" >> "$GITHUB_OUTPUT" | |
| echo "custom_domain=${{ env.DEFAULT_CUSTOM_DOMAIN }}" >> "$GITHUB_OUTPUT" | |
| echo "ace_box_name_prefix=${{ env.DEFAULT_ACE_BOX_NAME_PREFIX }}" >> "$GITHUB_OUTPUT" | |
| echo "dt_tenant=${{ env.DT_TENANT }}" >> "$GITHUB_OUTPUT" | |
| echo "dt_url_gen3=${{ env.DT_URL_GEN3 }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| shell: bash | |
| test_demo_usecases: | |
| needs: set_env_vars | |
| uses: ./.github/workflows/validation.yaml | |
| with: | |
| use_cases: ${{ needs.set_env_vars.outputs.use_cases }} | |
| providers: ${{ needs.set_env_vars.outputs.providers }} | |
| destroy_resources: ${{ needs.set_env_vars.outputs.destroy_resources == 'true' }} | |
| use_case_validation_tests_enabled: ${{ needs.set_env_vars.outputs.use_case_validation_tests_enabled == 'true' }} | |
| custom_domain: ${{ needs.set_env_vars.outputs.custom_domain }} | |
| ace_box_name_prefix: ${{ needs.set_env_vars.outputs.ace_box_name_prefix }} | |
| dt_tenant: ${{ needs.set_env_vars.outputs.dt_tenant }} | |
| dt_url_gen3: ${{ needs.set_env_vars.outputs.dt_url_gen3 }} | |
| dt_oauth_sso_endpoint: ${{ vars.DT_OAUTH_SSO_ENDPOINT }} | |
| dt_oauth_account_urn: ${{ vars.DT_OAUTH_ACCOUNT_URN }} | |
| secrets: | |
| dt_api_token: ${{ secrets.DT_API_TOKEN }} | |
| gcp_credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }} | |
| dt_oauth_client_id: ${{ secrets.DT_OAUTH_CLIENT_ID }} | |
| dt_oauth_client_secret: ${{ secrets.DT_OAUTH_CLIENT_SECRET }} |