deploy to aws #224
This file contains 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: deploy to aws | |
on: | |
workflow_dispatch: | |
inputs: | |
mfaCode: | |
type: string | |
description: MFA Code | |
required: true | |
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 | |
- name: AWS Authentication | |
env: | |
AWS_MFA_ARN: ${{ secrets.RESTRICTED_AWS_MFA_ARN }} | |
AWS_REGION: ${{ inputs.region }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.RESTRICTED_AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.RESTRICTED_AWS_SECRET_ACCESS_KEY }} | |
run: | | |
creds_json=$(aws sts get-session-token --serial-number ${AWS_MFA_ARN} --token-code ${{ inputs.mfaCode }}) | |
echo $creds_json > /tmp/creds_json | |
- 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: deploy | |
env: | |
AWS_REGION: ${{ inputs.region }} | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
GH_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }} | |
LAMBDA_PERF_ENV: ${{ inputs.lambdaPerfEnv }} | |
run: | | |
export AWS_ACCESS_KEY_ID=$(cat /tmp/creds_json | jq .Credentials.AccessKeyId |tr -d '"') | |
export AWS_SECRET_ACCESS_KEY=$(cat /tmp/creds_json | jq .Credentials.SecretAccessKey| tr -d '"') | |
export AWS_SESSION_TOKEN=$(cat /tmp/creds_json | jq .Credentials.SessionToken|tr -d '"') | |
sls deploy --force | |