From efb0b0e06b5b76a7c10d73beae4024aa946098f2 Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Wed, 18 Sep 2024 19:08:48 +0200 Subject: [PATCH] chore: trigger aws lambdas cleanup from github --- .../cleanup-staled-aws-e2e-resources.yml | 48 +++++++++++++++++++ buildspec-cleanup.yml | 1 + 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/cleanup-staled-aws-e2e-resources.yml diff --git a/.github/workflows/cleanup-staled-aws-e2e-resources.yml b/.github/workflows/cleanup-staled-aws-e2e-resources.yml new file mode 100644 index 00000000..f4c5bda4 --- /dev/null +++ b/.github/workflows/cleanup-staled-aws-e2e-resources.yml @@ -0,0 +1,48 @@ +name: AWS cleanup staled E2E lambdas + +on: + workflow_dispatch: + schedule: + - cron: '4 5 * * *' + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + run-cleanup-staled-aws-resources: + name: Run cleanup for staled e2e resources in AWS + runs-on: ubuntu-latest + steps: + - name: Git clone + uses: actions/checkout@v4 + - name: configure AWS credentials + 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}} + - name: Trigger AWS CodePipeline + run: | + codepipeline_execution_id=$(aws codepipeline start-pipeline-execution --name ${{vars.AWS_CLEANUP_E2E_LAMBDAS_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_CLEANUP_E2E_LAMBDAS_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/buildspec-cleanup.yml b/buildspec-cleanup.yml index b510b031..02adeeb9 100644 --- a/buildspec-cleanup.yml +++ b/buildspec-cleanup.yml @@ -3,6 +3,7 @@ version: 0.2 phases: install: commands: + - npm i -g pnpm - pnpm install build: commands: