|
| 1 | +name: Resize Deployment Server |
| 2 | + |
| 3 | +# Resize the release-tools deployment server |
| 4 | +# during releases. |
| 5 | +# |
| 6 | +# Boost Releases occur three time per year. |
| 7 | +# Before betas and release, increase the size of the deployment |
| 8 | +# server so publish_release.py will have more CPU. |
| 9 | +# |
| 10 | +# See initial setup instructions at the end of this file. |
| 11 | +# |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_dispatch: |
| 15 | + # Runs on Wednesday at 1:00am, on certain months. |
| 16 | + schedule: |
| 17 | + - cron: "0 1 * 3 3" |
| 18 | + - cron: "0 1 * 4 3" |
| 19 | + - cron: "0 1 * 7 3" |
| 20 | + - cron: "0 1 * 8 3" |
| 21 | + - cron: "0 1 * 11 3" |
| 22 | + - cron: "0 1 * 12 3" |
| 23 | + |
| 24 | +jobs: |
| 25 | + scale-deploy-server: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + container: amazon/aws-cli:2.32.19 |
| 28 | + name: Scale |
| 29 | + env: |
| 30 | + AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }} |
| 31 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }} |
| 32 | + if: github.repository == 'boostorg/release-tools' |
| 33 | + steps: |
| 34 | + - name: Debug |
| 35 | + run: | |
| 36 | + set -xe |
| 37 | + pwd |
| 38 | + whoami |
| 39 | + aws --version |
| 40 | + echo "github.event_name is ${{ github.event_name }}" |
| 41 | +
|
| 42 | + - name: Get number of Wednesday on a Wednesday |
| 43 | + id: number-of-wednesday-on-a-wednesday |
| 44 | + run: >- |
| 45 | + printf >> "$GITHUB_OUTPUT" |
| 46 | + "VALUE=%s" |
| 47 | + "$((($(date +%-d)-1)/7+1))" |
| 48 | + - name: Resize Instance |
| 49 | + if: ${{ ( steps.number-of-wednesday-on-a-wednesday.outputs.VALUE == 2 && github.event_name == 'schedule' ) || ( github.event_name == 'workflow_dispatch' ) }} |
| 50 | + run: | |
| 51 | + 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 }} |
| 52 | +
|
| 53 | +
|
| 54 | +# Initial Setup Instructions |
| 55 | +# |
| 56 | +# In AWS, create an instance. Install packages. |
| 57 | +# In AWS IAM, create a user, api keys, assign policies. |
| 58 | +# Assign policies to the user: EC2-Resize and AmazonSSMFullAccess(managed). |
| 59 | +# Create the policy EC2-Resize: |
| 60 | +# { |
| 61 | +# "Version": "2012-10-17", |
| 62 | +# "Statement": [ |
| 63 | +# { |
| 64 | +# "Sid": "Stmt1471613026000", |
| 65 | +# "Effect": "Allow", |
| 66 | +# "Action": [ |
| 67 | +# "ec2:ModifyInstanceAttribute" |
| 68 | +# ], |
| 69 | +# "Resource": "arn:aws:ec2:_region_:_account_:instance/_instance-id_, |
| 70 | +# "Condition": { |
| 71 | +# "StringEquals": { |
| 72 | +# "ec2:Attribute": "InstanceType" |
| 73 | +# } |
| 74 | +# } |
| 75 | +# }, |
| 76 | +# { |
| 77 | +# "Effect": "Allow", |
| 78 | +# "Action": [ |
| 79 | +# "ec2:DescribeInstances" |
| 80 | +# ], |
| 81 | +# "Resource": "*" |
| 82 | +# }, |
| 83 | +# { |
| 84 | +# "Effect": "Allow", |
| 85 | +# "Action": [ |
| 86 | +# "ec2:StartInstances", |
| 87 | +# "ec2:StopInstances" |
| 88 | +# ], |
| 89 | +# "Resource": "arn:aws:ec2:_region_:_account_:instance/_instance-id_, |
| 90 | +# } |
| 91 | +# ] |
| 92 | +# } |
| 93 | +# |
| 94 | +# Fill in _region_, _account_, and _instance-id_. |
| 95 | +# |
| 96 | +# Add github actions secrets: |
| 97 | +# |
| 98 | +# DEPLOY_INSTANCE_ID |
| 99 | +# DEPLOY_REGION |
| 100 | +# DEPLOY_AWS_ACCESS_KEY_ID |
| 101 | +# DEPLOY_AWS_SECRET_ACCESS_KEY |
0 commit comments