diff --git a/.github/workflows/deploy-server-reduce.yml b/.github/workflows/deploy-server-reduce.yml new file mode 100644 index 0000000..da10f27 --- /dev/null +++ b/.github/workflows/deploy-server-reduce.yml @@ -0,0 +1,36 @@ +name: Resize (Reduce) Deployment Server + +# Reduce the size of the release-tools deployment server +# +# The other workflow file increases the instance size during +# releases. +# +# This one reduces it again, each Sunday. +# + +on: + workflow_dispatch: + schedule: + - cron: "0 1 * * 0" + +jobs: + scale-deploy-server: + runs-on: ubuntu-latest + container: amazon/aws-cli:2.32.19 + name: Scale + env: + AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }} + if: github.repository == 'boostorg/release-tools' + steps: + - name: Debug + run: | + set -xe + pwd + whoami + aws --version + echo "github.event_name is ${{ github.event_name }}" + + - name: Resize Instance + run: | + aws ssm start-automation-execution --document-name "AWS-ResizeInstance" --document-version "\$DEFAULT" --parameters '{"InstanceId":["${{ secrets.DEPLOY_INSTANCE_ID }}"],"InstanceType":["t2.micro"],"SleepWait":["PT5S"]}' --region ${{ secrets.DEPLOY_REGION }} diff --git a/.github/workflows/deploy-server-resize.yml b/.github/workflows/deploy-server-resize.yml new file mode 100644 index 0000000..e0c583e --- /dev/null +++ b/.github/workflows/deploy-server-resize.yml @@ -0,0 +1,101 @@ +name: Resize Deployment Server + +# Resize the release-tools deployment server +# during releases. +# +# Boost Releases occur three time per year. +# Before betas and release, increase the size of the deployment +# server so publish_release.py will have more CPU. +# +# See initial setup instructions at the end of this file. +# + +on: + workflow_dispatch: + # Runs on Wednesday at 1:00am, on certain months. + schedule: + - cron: "0 1 * 3 3" + - cron: "0 1 * 4 3" + - cron: "0 1 * 7 3" + - cron: "0 1 * 8 3" + - cron: "0 1 * 11 3" + - cron: "0 1 * 12 3" + +jobs: + scale-deploy-server: + runs-on: ubuntu-latest + container: amazon/aws-cli:2.32.19 + name: Scale + env: + AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }} + if: github.repository == 'boostorg/release-tools' + steps: + - name: Debug + run: | + set -xe + pwd + whoami + aws --version + echo "github.event_name is ${{ github.event_name }}" + + - name: Get number of Wednesday on a Wednesday + id: number-of-wednesday-on-a-wednesday + run: >- + printf >> "$GITHUB_OUTPUT" + "VALUE=%s" + "$((($(date +%-d)-1)/7+1))" + - name: Resize Instance + if: ${{ ( steps.number-of-wednesday-on-a-wednesday.outputs.VALUE == 2 && github.event_name == 'schedule' ) || ( github.event_name == 'workflow_dispatch' ) }} + run: | + aws ssm start-automation-execution --document-name "AWS-ResizeInstance" --document-version "\$DEFAULT" --parameters '{"InstanceId":["${{ secrets.DEPLOY_INSTANCE_ID }}"],"InstanceType":["c8a.xlarge"],"SleepWait":["PT5S"]}' --region ${{ secrets.DEPLOY_REGION }} + + +# Initial Setup Instructions +# +# In AWS, create an instance. Install packages. +# In AWS IAM, create a user, api keys, assign policies. +# Assign policies to the user: EC2-Resize and AmazonSSMFullAccess(managed). +# Create the policy EC2-Resize: +# { +# "Version": "2012-10-17", +# "Statement": [ +# { +# "Sid": "Stmt1471613026000", +# "Effect": "Allow", +# "Action": [ +# "ec2:ModifyInstanceAttribute" +# ], +# "Resource": "arn:aws:ec2:_region_:_account_:instance/_instance-id_, +# "Condition": { +# "StringEquals": { +# "ec2:Attribute": "InstanceType" +# } +# } +# }, +# { +# "Effect": "Allow", +# "Action": [ +# "ec2:DescribeInstances" +# ], +# "Resource": "*" +# }, +# { +# "Effect": "Allow", +# "Action": [ +# "ec2:StartInstances", +# "ec2:StopInstances" +# ], +# "Resource": "arn:aws:ec2:_region_:_account_:instance/_instance-id_, +# } +# ] +# } +# +# Fill in _region_, _account_, and _instance-id_. +# +# Add github actions secrets: +# +# DEPLOY_INSTANCE_ID +# DEPLOY_REGION +# DEPLOY_AWS_ACCESS_KEY_ID +# DEPLOY_AWS_SECRET_ACCESS_KEY