diff --git a/.github/workflows/deploy-front-qa.yml b/.github/workflows/deploy-front-qa.yml new file mode 100644 index 000000000000..4b62ab9e6a55 --- /dev/null +++ b/.github/workflows/deploy-front-qa.yml @@ -0,0 +1,77 @@ +name: Deploy Front QA + +on: + pull_request: + types: [closed] + branches: + - main + paths-ignore: + - "**.md" + workflow_dispatch: + +concurrency: + group: deploy_front_qa + cancel-in-progress: false + +env: + GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + # We skip running the build and deploy if the PR contains a migration represented by the 'migration-ack' label. + if: ${{ !contains(github.event.pull_request.labels.*.name, 'migration-ack') }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get short sha + id: short_sha + run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: "Authenticate with Google Cloud" + uses: "google-github-actions/auth@v1" + with: + credentials_json: "${{ secrets.GCLOUD_SA_KEY }}" + + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v1" + + - name: Build the image on Cloud Build + run: | + chmod +x ./k8s/cloud-build.sh + ./k8s/cloud-build.sh \ + --image-name=front-qa \ + --dockerfile-path=./front/Dockerfile \ + --working-dir=./ \ + --dust-client-facing-url=https://front-qa.dust.tt + + - name: Generate a token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.INFRA_DISPATCH_APP_ID }} + private-key: ${{ secrets.INFRA_DISPATCH_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + dust-infra + + - name: Trigger dust-infra workflow + uses: actions/github-script@v6 + with: + github-token: ${{ steps.generate-token.outputs.token }} + script: | + await github.rest.repos.createDispatchEvent({ + owner: '${{ github.repository_owner }}', + repo: 'dust-infra', + event_type: 'trigger-component-deploy', + client_payload: { + regions: 'us-central1', + component: 'front-qa', + image_tag: '${{ steps.short_sha.outputs.short_sha }}', + run_playwright: true, + playwright_sha: '${{ github.sha }}', + repository_name: '${{ github.event.repository.name }}' + } + }); \ No newline at end of file diff --git a/.github/workflows/deploy-and-test-front-qa.yml b/.github/workflows/run-playwright-tests.yml similarity index 57% rename from .github/workflows/deploy-and-test-front-qa.yml rename to .github/workflows/run-playwright-tests.yml index 0bdfb92c8db4..75861a4573b5 100644 --- a/.github/workflows/deploy-and-test-front-qa.yml +++ b/.github/workflows/run-playwright-tests.yml @@ -1,80 +1,19 @@ -name: Deploy And test Front Qa +name: Run Playwright Tests on: - pull_request: - types: [closed] - branches: - - main - paths-ignore: - - "**.md" - workflow_dispatch: - -concurrency: - group: deploy_front_qa - cancel-in-progress: false - -env: - GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} - IMAGE_NAME: front-qa + repository_dispatch: + types: [run-playwright-tests] jobs: - build-and-deploy: - runs-on: ubuntu-latest - - # We skip running the build and deploy if the PR contains a migration represented by the 'migration-ack' label. - if: ${{ !contains(github.event.pull_request.labels.*.name, 'migration-ack') }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Get short sha - id: short_sha - run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - - name: "Authenticate with Google Cloud" - uses: "google-github-actions/auth@v1" - with: - credentials_json: "${{ secrets.GCLOUD_SA_KEY }}" - - - name: "Set up Cloud SDK" - uses: "google-github-actions/setup-gcloud@v1" - - - name: Install gke-gcloud-auth-plugin - run: | - gcloud components install gke-gcloud-auth-plugin - - - name: Setup kubectl - run: | - gcloud container clusters get-credentials dust-kube --region us-central1 - - - name: Build the image on Cloud Build - run: | - chmod +x ./k8s/cloud-build.sh - ./k8s/cloud-build.sh --image-name=$IMAGE_NAME --dockerfile-path=./front/Dockerfile --working-dir=./ --dust-client-facing-url=https://front-qa.dust.tt - - - name: Deploy the image on Kubernetes - run: | - chmod +x ./k8s/deploy-image.sh - ./k8s/deploy-image.sh gcr.io/$GCLOUD_PROJECT_ID/$IMAGE_NAME-image:${{ steps.short_sha.outputs.short_sha }} front-qa-deployment - - - name: Wait for rollout to complete - run: kubectl rollout status deployment/front-qa-deployment --timeout=10m - run-playwright-tests: - needs: build-and-deploy - runs-on: ubuntu-latest - # We skip running the build and deploy if the PR contains a migration represented by the 'migration-ack' label. - if: ${{ !contains(github.event.pull_request.labels.*.name, 'migration-ack') }} - steps: - name: Run Playwright Tests id: trigger-tests env: REPO_OWNER: ${{ github.repository_owner }} - REPO_NAME: ${{ github.event.repository.name }} + REPO_NAME: ${{ github.event.client_payload.repository_name }} run: | response=$(curl -s -w "\n%{http_code}" -X POST "https://webhook.ranger.net/api/v1/tests/run" \ -H "Content-Type: application/json" \ @@ -83,7 +22,7 @@ jobs: "targetUrl": "https://front-qa.dust.tt/", "ghOwner": "'$REPO_OWNER'", "ghRepo": "'$REPO_NAME'", - "ghCommitSha": "${{ github.sha }}" + "ghCommitSha": "${{ github.event.client_payload.sha }}" }') echo "$response" http_code=$(echo "$response" | tail -n1) @@ -139,13 +78,13 @@ jobs: with: payload: | { - "text": "⚠️ Playwright tests failed! Commit: ${{ github.sha }} | PR merged by @${{ github.event.pull_request.user.login }} into main. Title: ${{ github.event.pull_request.title }} | Check ID: ${{ env.CHECK_ID }}", + "text": "⚠️ Playwright tests failed! Commit: ${{ github.event.client_payload.sha }} | PR merged by @${{ github.event.pull_request.user.login }} into main. Title: ${{ github.event.pull_request.title }} | Check ID: ${{ env.CHECK_ID }}", "blocks": [ { "type": "section", "text": { "type": "plain_text", - "text": "⚠️ Playwright tests failed! Commit: ${{ github.sha }} | PR merged by @${{ github.event.pull_request.user.login }} into main. Title: ${{ github.event.pull_request.title }} | Check ID: ${{ env.CHECK_ID }}", + "text": "⚠️ Playwright tests failed! Commit: ${{ github.event.client_payload.sha }} | PR merged by @${{ github.event.pull_request.user.login }} into main. Title: ${{ github.event.pull_request.title }} | Check ID: ${{ env.CHECK_ID }}", "emoji": true }, "accessory": {