From edf957696c9f5b7cfdb6696cdb6900a8dc11bfe7 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Tue, 17 Sep 2024 14:30:10 +0300 Subject: [PATCH 1/2] ci: change trigger condition and rename e2e test for releases pipeline --- .github/workflows/e2e_test_branch.yml | 50 +++++++++++++++++++ ...e2e_test.yml => e2e_test_for_releases.yml} | 11 ++-- 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/e2e_test_branch.yml rename .github/workflows/{e2e_test.yml => e2e_test_for_releases.yml} (88%) diff --git a/.github/workflows/e2e_test_branch.yml b/.github/workflows/e2e_test_branch.yml new file mode 100644 index 00000000..5c895464 --- /dev/null +++ b/.github/workflows/e2e_test_branch.yml @@ -0,0 +1,50 @@ +name: AWS E2E on test branch + +on: + workflow_dispatch: + workflow_run: + workflows: [Deploy test branch] + types: + - completed + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + RunE2E: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Git clone + uses: actions/checkout@v4 + - name: configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} + aws-region: ${{secrets.AWS_E2E_REGION}} + - name: Trigger AWS CodePipeline + run: | + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_TEST_BRANCH_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) + echo "Pipeline execution ID: $codepipeline_execution_id" + echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV + - name: Poll Pipeline Status + id: poll-status + run: | + while true; do + sleep 30 + status=$(aws codepipeline get-pipeline-execution \ + --pipeline-name ${{vars.AWS_E2E_TEST_BRANCH_CODEPIPELINE_NAME}} \ + --pipeline-execution-id ${{ env.codepipeline_execution_id }} \ + --query 'pipelineExecution.status' --output text) + + echo "Current pipeline status: $status" + + if [[ "$status" == "Succeeded" ]]; then + echo "Pipeline execution succeeded!" + exit 0 + elif [[ "$status" == "Failed" ]]; then + echo "Pipeline execution failed!" + exit 1 + fi + done diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test_for_releases.yml similarity index 88% rename from .github/workflows/e2e_test.yml rename to .github/workflows/e2e_test_for_releases.yml index 16f917cd..13273b63 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test_for_releases.yml @@ -1,11 +1,10 @@ -name: AWS E2E +name: AWS E2E for releases and pre-releases on: workflow_dispatch: push: - branches: - - main - - rc + tags: + - v* paths-ignore: - '**.md' - 'cloudformation/*.yml' @@ -27,7 +26,7 @@ jobs: aws-region: ${{secrets.AWS_E2E_REGION}} - name: Trigger AWS CodePipeline run: | - codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{secrets.AWS_E2E_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_E2E_RC_CODEPIPELINE_NAME}} --query 'pipelineExecutionId' --output text) echo "Pipeline execution ID: $codepipeline_execution_id" echo "codepipeline_execution_id=$codepipeline_execution_id" >> $GITHUB_ENV - name: Poll Pipeline Status @@ -37,7 +36,7 @@ jobs: sleep 30 status=$(aws codepipeline get-pipeline-execution \ - --pipeline-name ${{secrets.AWS_E2E_CODEPIPELINE_NAME}} \ + --pipeline-name ${{vars.AWS_E2E_RC_CODEPIPELINE_NAME}} \ --pipeline-execution-id ${{ env.codepipeline_execution_id }} \ --query 'pipelineExecution.status' --output text) From e43cf1df30db615bef4cfdd03300dd78bcae7c55 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Tue, 17 Sep 2024 15:03:57 +0300 Subject: [PATCH 2/2] ci: use commit id instead of version --- .github/workflows/e2e_test_branch.yml | 2 +- .github/workflows/e2e_test_for_releases.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e_test_branch.yml b/.github/workflows/e2e_test_branch.yml index 5c895464..16bb863f 100644 --- a/.github/workflows/e2e_test_branch.yml +++ b/.github/workflows/e2e_test_branch.yml @@ -19,7 +19,7 @@ jobs: - name: Git clone uses: actions/checkout@v4 - name: configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 // #v4.0.2 with: role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} aws-region: ${{secrets.AWS_E2E_REGION}} diff --git a/.github/workflows/e2e_test_for_releases.yml b/.github/workflows/e2e_test_for_releases.yml index 13273b63..1013409d 100644 --- a/.github/workflows/e2e_test_for_releases.yml +++ b/.github/workflows/e2e_test_for_releases.yml @@ -20,7 +20,7 @@ jobs: - name: Git clone uses: actions/checkout@v4 - name: configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 // #v4.0.2 with: role-to-assume: ${{secrets.AWS_E2E_ROLE_ARN}} aws-region: ${{secrets.AWS_E2E_REGION}}