Skip to content

Commit

Permalink
uncomment CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmizerany committed Feb 12, 2024
1 parent 5641620 commit 37e47b6
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions .github/workflows/terminate-zombie-build-instances.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@
# can take up to 3 hours. Set this to 3 hours to include these longer runs.
# name: Terminate Zombie Build Instances

# on:
# workflow_dispatch:
# schedule:
# - cron: "0 */1 * * *"
on:
workflow_dispatch:
schedule:
- cron: "0 */1 * * *"

# jobs:
# terminate:
# runs-on: ubuntu-latest
# steps:
# - name: List and Terminate Instances Older Than 4 Hours
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
# # See https://github.com/aws/aws-cli/issues/5623
# AWS_EC2_METADATA_DISABLED: true
# run: |
# set -euxo pipefail
jobs:
terminate:
runs-on: ubuntu-latest
steps:
- name: List and Terminate Instances Older Than 4 Hours
env:
AWS_ACCESS_KEY_ID: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
# See https://github.com/aws/aws-cli/issues/5623
AWS_EC2_METADATA_DISABLED: true
run: |
set -euxo pipefail
# export TIME_LIMIT=14400 # 4 hours
export TIME_LIMIT=14400 # 4 hours
# aws configure set default.region us-east-2
aws configure set default.region us-east-2
# # See https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-instances.html for describe command.
# # Since the AWS cli returns an ISO HH:MM timestamp, and Jq only accepts Z timestamps, we define a function toZ to convert this.
# export to_terminate=$(aws ec2 describe-instances --no-paginate --filters --filters 'Name=tag:Repository,Values=airbytehq/airbyte-platform-internal,airbytehq/airbyte-platform,airbytehq/airbyte' Name=instance-state-name,Values=running \
# --query 'Reservations[*].Instances[*].{Instance:InstanceId,LaunchTime:LaunchTime}' --output json \
# | jq 'def toZ(str): str | (split("+")[0] + "Z") | fromdate ;
# flatten | map( { InstanceId: .Instance, LaunchTime: toZ(.LaunchTime) } ) | map( select ( .LaunchTime < (now - (env.TIME_LIMIT|tonumber)) ) )')
# See https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-instances.html for describe command.
# Since the AWS cli returns an ISO HH:MM timestamp, and Jq only accepts Z timestamps, we define a function toZ to convert this.
export to_terminate=$(aws ec2 describe-instances --no-paginate --filters --filters 'Name=tag:Repository,Values=airbytehq/airbyte-platform-internal,airbytehq/airbyte-platform,airbytehq/airbyte' Name=instance-state-name,Values=running \
--query 'Reservations[*].Instances[*].{Instance:InstanceId,LaunchTime:LaunchTime}' --output json \
| jq 'def toZ(str): str | (split("+")[0] + "Z") | fromdate ;
flatten | map( { InstanceId: .Instance, LaunchTime: toZ(.LaunchTime) } ) | map( select ( .LaunchTime < (now - (env.TIME_LIMIT|tonumber)) ) )')
# echo "MARKED FOR TERMINATION: ${to_terminate}"
echo "MARKED FOR TERMINATION: ${to_terminate}"
# # See https://docs.aws.amazon.com/cli/latest/reference/ec2/terminate-instances.html for terminate command.
# echo $to_terminate | jq '.[] | .InstanceId' | xargs --no-run-if-empty --max-args=1 aws ec2 terminate-instances --instance-ids
# terminate-github-instances:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Airbyte
# uses: actions/checkout@v3
# - name: List and Terminate GH actions in status 'offline'
# env:
# GITHUB_PAT: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
# run: ./tools/bin/gh_action_zombie_killer
# See https://docs.aws.amazon.com/cli/latest/reference/ec2/terminate-instances.html for terminate command.
echo $to_terminate | jq '.[] | .InstanceId' | xargs --no-run-if-empty --max-args=1 aws ec2 terminate-instances --instance-ids
terminate-github-instances:
runs-on: ubuntu-latest
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
- name: List and Terminate GH actions in status 'offline'
env:
GITHUB_PAT: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
run: ./tools/bin/gh_action_zombie_killer

0 comments on commit 37e47b6

Please sign in to comment.