Scheduled Deploy #436
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Scheduled Deploy | |
| on: | |
| schedule: | |
| # Each timezone deploys at their local 4 AM | |
| - cron: '0 9 * * *' # 4 AM Eastern (UTC-5) | |
| - cron: '0 10 * * *' # 4 AM Central (UTC-6) | |
| - cron: '0 11 * * *' # 4 AM Mountain (UTC-7) | |
| - cron: '0 12 * * *' # 4 AM Pacific (UTC-8) | |
| workflow_dispatch: | |
| inputs: | |
| timezone: | |
| description: 'Which timezone group to deploy' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - eastern | |
| - central | |
| - mountain | |
| - pacific | |
| env: | |
| AWS_REGION: us-east-1 # Change to your EC2 region | |
| EASTERN_SERVICES: "mbta wmata_bus wmata_rail septa_bus septa_rail cats_charlotte_nc ct_transit marta_bus pvta ripta toronto_ttc" | |
| CENTRAL_SERVICES: "nashvillemta" | |
| MOUNTAIN_SERVICES: "denver_rtd" | |
| PACIFIC_SERVICES: "caltrain king_county_metro" | |
| jobs: | |
| deploy-eastern: | |
| runs-on: ubuntu-latest | |
| if: > | |
| (github.event_name == 'schedule' && github.event.schedule == '0 9 * * *') || | |
| (github.event_name == 'workflow_dispatch' && (inputs.timezone == 'eastern' || inputs.timezone == 'all')) | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Deploy Eastern timezone services (4 AM ET) | |
| run: | | |
| aws ssm send-command \ | |
| --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ | |
| --document-name "AWS-RunShellScript" \ | |
| --parameters 'commands=[ | |
| "cd ${{ secrets.EC2_DEPLOY_PATH }}", | |
| "for service in ${{ env.EASTERN_SERVICES }}; do echo Deploying $service...; docker compose pull $service; docker compose up -d --no-deps $service; sleep 5; done", | |
| "docker image prune -f" | |
| ]' \ | |
| --output text | |
| deploy-central: | |
| runs-on: ubuntu-latest | |
| if: > | |
| (github.event_name == 'schedule' && github.event.schedule == '0 10 * * *') || | |
| (github.event_name == 'workflow_dispatch' && (inputs.timezone == 'central' || inputs.timezone == 'all')) | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Deploy Central timezone services (4 AM CT) | |
| run: | | |
| aws ssm send-command \ | |
| --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ | |
| --document-name "AWS-RunShellScript" \ | |
| --parameters 'commands=[ | |
| "cd ${{ secrets.EC2_DEPLOY_PATH }}", | |
| "for service in ${{ env.CENTRAL_SERVICES }}; do echo Deploying $service...; docker compose pull $service; docker compose up -d --no-deps $service; sleep 5; done", | |
| "docker image prune -f" | |
| ]' \ | |
| --output text | |
| deploy-mountain: | |
| runs-on: ubuntu-latest | |
| if: > | |
| (github.event_name == 'schedule' && github.event.schedule == '0 11 * * *') || | |
| (github.event_name == 'workflow_dispatch' && (inputs.timezone == 'mountain' || inputs.timezone == 'all')) | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Deploy Mountain timezone services (4 AM MT) | |
| run: | | |
| aws ssm send-command \ | |
| --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ | |
| --document-name "AWS-RunShellScript" \ | |
| --parameters 'commands=[ | |
| "cd ${{ secrets.EC2_DEPLOY_PATH }}", | |
| "for service in ${{ env.MOUNTAIN_SERVICES }}; do echo Deploying $service...; docker compose pull $service; docker compose up -d --no-deps $service; sleep 5; done", | |
| "docker image prune -f" | |
| ]' \ | |
| --output text | |
| deploy-pacific: | |
| runs-on: ubuntu-latest | |
| if: > | |
| (github.event_name == 'schedule' && github.event.schedule == '0 12 * * *') || | |
| (github.event_name == 'workflow_dispatch' && (inputs.timezone == 'pacific' || inputs.timezone == 'all')) | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Deploy Pacific timezone services (4 AM PT) | |
| run: | | |
| aws ssm send-command \ | |
| --instance-ids "${{ secrets.EC2_INSTANCE_ID }}" \ | |
| --document-name "AWS-RunShellScript" \ | |
| --parameters 'commands=[ | |
| "cd ${{ secrets.EC2_DEPLOY_PATH }}", | |
| "for service in ${{ env.PACIFIC_SERVICES }}; do echo Deploying $service...; docker compose pull $service; docker compose up -d --no-deps $service; sleep 5; done", | |
| "docker image prune -f" | |
| ]' \ | |
| --output text |