Add build and push on latest tag (#97) #22
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 easytrade on main | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - .github/** | |
| - kubernetes-manifests/** | |
| - skaffold.yaml | |
| - src/** | |
| - helm/** | |
| workflow_dispatch: | |
| inputs: | |
| run-tests: | |
| description: "Run integration tests after deployment?" | |
| required: false | |
| type: boolean | |
| default: true | |
| workflow_call: | |
| secrets: | |
| GAR_CREDENTIALS: | |
| required: true | |
| KUBECONFIG: | |
| required: true | |
| OQR_CLIENT_ID: | |
| required: true | |
| OQR_CLIENT_SECRET: | |
| required: true | |
| OQR_URL: | |
| required: true | |
| SNYK_API_TOKEN: | |
| required: true | |
| SSH_PRIVATE_KEY: | |
| required: true | |
| SSO_URL: | |
| required: true | |
| env: | |
| GAR_ADDRESS: europe-docker.pkg.dev | |
| NAMESPACE: easytrade | |
| CONTAINER_REGISTRY: europe-docker.pkg.dev/dynatrace-demoability/docker/easytrade | |
| HELM_REGISTRY: oci://europe-docker.pkg.dev/dynatrace-demoability/helm | |
| HELM_CHART_PATH: helm/easytrade | |
| VERSION: 1.2.${{ github.run_number }} | |
| jobs: | |
| snyk: | |
| uses: ./.github/workflows/snyk.yaml | |
| permissions: | |
| security-events: write | |
| contents: read | |
| actions: read | |
| secrets: | |
| SNYK_API_TOKEN: ${{ secrets.SNYK_API_TOKEN }} | |
| build-easytrade: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Retrieve gar credentials | |
| run: | | |
| echo "${{ secrets.GAR_CREDENTIALS }}" | docker login -u _json_key_base64 --password-stdin "${{ env.GAR_ADDRESS }}" | |
| - name: Set application version | |
| uses: ./.github/actions/set-version | |
| with: | |
| version: ${{ env.VERSION }} | |
| - name: Build and push easytrade to docker repository | |
| uses: ./.github/actions/build-push-images | |
| with: | |
| push: true | |
| push-latest: true | |
| tag: ${{ env.VERSION }} | |
| registry: ${{ env.CONTAINER_REGISTRY }} | |
| - name: Build and push Helm chart | |
| uses: ./.github/actions/build-push-helm | |
| with: | |
| chart-path: ${{ env.HELM_CHART_PATH }} | |
| push: true | |
| registry-url: oci://europe-docker.pkg.dev/dynatrace-demoability/helm | |
| version: ${{ env.VERSION }} | |
| credentials: ${{ secrets.GAR_CREDENTIALS }} | |
| deploy-easytrade: | |
| runs-on: ubuntu-24.04 | |
| needs: build-easytrade | |
| steps: | |
| - name: Retrieve kubeconfig | |
| run: | | |
| mkdir ~/.kube | |
| echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config | |
| - name: Checkout infrastructure repo | |
| uses: actions/checkout@v6 | |
| with: | |
| ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| repository: dynatrace/easytrade-infrastructure | |
| path: easytrade-infrastructure | |
| - name: Deploy easytrade | |
| shell: bash | |
| env: | |
| HELM_CHART_VERSION: ${{ env.VERSION }} | |
| BASE_VALUES_FILE: "./helm-values/aws-base.yaml" | |
| OVERRIDES_VALUES_FILE: "./helm-values/aws-staging.yaml" | |
| DRY_RUN: "false" | |
| DEBUG_MODE: "false" | |
| run: ./deploy.sh | |
| working-directory: ${{ github.workspace }}/easytrade-infrastructure | |
| run-tests: | |
| if: ${{ inputs.run-tests == 'true' }} | |
| runs-on: ubuntu-24.04 | |
| needs: deploy-easytrade | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Retrieve kubeconfig | |
| run: | | |
| mkdir ~/.kube | |
| echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config | |
| - name: Enable test environment | |
| run: | | |
| kubectl -n ${{ env.NAMESPACE }} set env deployment/easytrade-credit-card-order-service WORK_DELAY=10 WORK_RATE=10 | |
| kubectl -n ${{ env.NAMESPACE }} set env deployment/easytrade-third-party-service COURIER_DELAY=10 COURIER_RATE=10 MANUFACTURE_DELAY=10 MANUFACTURE_RATE=10 | |
| - name: Wait 3 minutes | |
| run: sleep 3m | |
| - name: Order credit card | |
| uses: ./.github/actions/order-credit-card | |
| with: | |
| namespace: ${{ env.NAMESPACE }} | |
| - name: Wait 12 minutes | |
| run: sleep 12m | |
| - name: Check credit card order | |
| uses: ./.github/actions/check-credit-card-order | |
| with: | |
| namespace: ${{ env.NAMESPACE }} | |
| - name: Run validation | |
| uses: ./.github/actions/run-validation | |
| with: | |
| client_id: ${{ secrets.OQR_CLIENT_ID }} | |
| client_secret: ${{ secrets.OQR_CLIENT_SECRET }} | |
| sso_url: ${{ secrets.SSO_URL }} | |
| tenant_url: ${{ secrets.OQR_URL }} | |
| - name: Disable test environment | |
| run: | | |
| kubectl -n ${{ env.NAMESPACE }} rollout undo deployment/easytrade-credit-card-order-service deployment/easytrade-third-party-service |