From 684fdc36d510bd156817d78351c11e03afe20a43 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sat, 7 Sep 2024 19:40:15 +0100 Subject: [PATCH] Allow keeping EC2 instances after workflow failures --- .github/workflows/bench_ec2_any.yml | 4 ++++ .github/workflows/bench_ec2_reusable.yml | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bench_ec2_any.yml b/.github/workflows/bench_ec2_any.yml index 5fb744560..20c8ccc52 100644 --- a/.github/workflows/bench_ec2_any.yml +++ b/.github/workflows/bench_ec2_any.yml @@ -20,6 +20,9 @@ on: store_results: description: Indicates if results should be pushed to github pages default: false + always_terminate: + description: Indicates if EC2 instance should always be terminated + default: true jobs: bench-ec2-any: name: Ad-hoc benchmark on $${{ github.event.inputs.ec2_instance_type }} @@ -31,4 +34,5 @@ jobs: archflags: ${{ github.event.inputs.archflags }} name: ${{ github.event.inputs.name }} store_results: ${{ github.event.inputs.store_results }} + always_terminate: ${{ github.event.inputs.always_terminate }} secrets: inherit diff --git a/.github/workflows/bench_ec2_reusable.yml b/.github/workflows/bench_ec2_reusable.yml index cbbdf25a2..6f935b6c8 100644 --- a/.github/workflows/bench_ec2_reusable.yml +++ b/.github/workflows/bench_ec2_reusable.yml @@ -26,6 +26,10 @@ on: type: string description: Indicates if results should be pushed to github pages default: 'false' + always_terminate: + type: string + description: Indicates if instance should always be terminated, even on failure + default: 'true' env: AWS_ROLE: arn:aws:iam::559050233797:role/mlkem-c-aarch64-gh-action AWS_REGION: us-east-1 @@ -106,7 +110,7 @@ jobs: - start-ec2-runner - bench # required to wait when the main job is done runs-on: ubuntu-latest - if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs + if: ${{ (inputs.always_terminate == 'true' && always()) || success() }} # required to stop the runner even if the error happened in the previous jobs steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4