Skip to content

deploy to aws

deploy to aws #233

Workflow file for this run

name: deploy to aws
permissions:
id-token: write
contents: read
on:
workflow_dispatch:
inputs:
region:
description: 'region on which you want to deploy'
type: choice
options:
- eu-west-1
- us-east-1
required: true
lambdaPerfEnv:
description: 'environment on which you want to deploy'
type: choice
options:
- staging
- production
required: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install Zig toolchain
uses: korandoru/setup-zig@v1
with:
zig-version: 0.10.0
- name: Install Cargo Lambda
uses: jaxxstorm/action-install-gh-release@v1.9.0
with:
repo: cargo-lambda/cargo-lambda
platform: linux
arch: x86_64
- name: test
run: cargo test
- name: build
run: ./build.sh
- name: install dependencies
run: |
cd ./result-builder && yarn install
- name: install Serverless Framework
run: sudo yarn global add serverless@^3.27.0 --prefix /usr/local
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: GitHub_Action_LambdaPerf_Session
aws-region: ${{ inputs.region }}
- name: deploy
env:
AWS_REGION: ${{ inputs.region }}
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
LAMBDA_PERF_ENV: ${{ inputs.lambdaPerfEnv }}
run: sls deploy --force
- name: Remove the cron job scheduler in staging (eu-west-1)
if: "${{ inputs.region == 'eu-west-1' }}"
run: |
RULE_NAME=$(aws events list-rule-names-by-target --target-arn arn:aws:lambda:${{ inputs.region }}:${{ secrets.AWS_ACCOUNT_ID }}:function:lambda-perf-dev-functionTriggerDeployerRs --region ${{ inputs.region }} | jq -r '.RuleNames[0]')
echo "Disabling rule ${RULE_NAME}"
aws events disable-rule --name $RULE_NAME --region ${{ inputs.region }}
RULE_NAME=$(aws events list-rule-names-by-target --target-arn arn:aws:lambda:${{ inputs.region }}:${{ secrets.AWS_ACCOUNT_ID }}:function:lambda-perf-dev-resultBuilder --region ${{ inputs.region }} | jq -r '.RuleNames[0]')
echo "Disabling rule ${RULE_NAME}"
aws events disable-rule --name $RULE_NAME --region ${{ inputs.region }}