-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
143 additions
and
110 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: deploy to aws | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
mfaCode: | ||
type: string | ||
description: MFA Code | ||
required: true | ||
region: | ||
description: 'region on which you want to deploy' | ||
type: choice | ||
|
@@ -36,15 +36,6 @@ jobs: | |
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- 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 | ||
|
@@ -66,23 +57,21 @@ jobs: | |
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/[email protected] | ||
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 }} | ||
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 | ||
run: sls deploy --force | ||
- name: Remove the cron job scheduler in staging (eu-west-1) | ||
if: "${{ inputs.region == 'eu-west-1' }}" | ||
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 '"') | ||
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 }} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: build and upload container to ECR | ||
name: AWS publish artifacts to ECR | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
mfaCode: | ||
type: string | ||
description: MFA Code | ||
required: true | ||
region: | ||
description: 'region on which you want to deploy' | ||
type: choice | ||
|
@@ -27,6 +27,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
outputs: | ||
runner: ${{ steps.select.outputs.runner }} | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Check branch | ||
id: select | ||
|
@@ -37,11 +38,27 @@ jobs: | |
echo "runner=self-hosted" >> $GITHUB_OUTPUT | ||
fi | ||
cat $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
- name: Build runtime matrix | ||
id: set-matrix | ||
run: | | ||
jq -c '[.runtimes[] | select(.architectures | index("arm64")) | select(.image != null and .image.baseImage != null) | .path]' manifest.json | ||
echo "matrix=$(jq -c '[.runtimes[] | select(.architectures | index("${{ inputs.architecture }}")) | select(.image != null and .image.baseImage != null) | .path]' manifest.json)" >> $GITHUB_OUTPUT | ||
build-upload: | ||
needs: setup | ||
runs-on: ${{ needs.setup.outputs.runner }} | ||
strategy: | ||
matrix: | ||
runtime_id: ${{fromJson(needs.setup.outputs.matrix)}} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: configure aws credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | ||
role-session-name: GitHub_Action_LambdaPerf_Session | ||
aws-region: ${{ inputs.region }} | ||
- name: Delete huge unnecessary folders | ||
run: | | ||
rm -rf /opt/hostedtoolcache | ||
|
@@ -52,19 +69,26 @@ jobs: | |
env: | ||
ARCHITECTURE: ${{ inputs.architecture }} | ||
AWS_REGION: ${{ inputs.region }} | ||
ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.RESTRICTED_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.RESTRICTED_AWS_SECRET_ACCESS_KEY }} | ||
AWS_MFA_ARN: ${{ secrets.RESTRICTED_AWS_MFA_ARN }} | ||
RUNTIME_ID: ${{ matrix.runtime_id }} | ||
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | ||
run: | | ||
creds_json=$(aws sts get-session-token --serial-number ${AWS_MFA_ARN} --token-code ${{ inputs.mfaCode }}) | ||
export AWS_ACCESS_KEY_ID=$(echo "$creds_json" | jq .Credentials.AccessKeyId |tr -d '"') | ||
export AWS_SECRET_ACCESS_KEY=$(echo "$creds_json" | jq .Credentials.SecretAccessKey| tr -d '"') | ||
export AWS_SESSION_TOKEN=$(echo "$creds_json" | jq .Credentials.SessionToken|tr -d '"') | ||
cd container-uploader | ||
yarn install | ||
node app.mjs | ||
clean-untagged-image: | ||
needs: build-upload | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: configure aws credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | ||
role-session-name: GitHub_Action_LambdaPerf_Session | ||
aws-region: ${{ inputs.region }} | ||
- name: clean untagged images | ||
env: | ||
AWS_REGION: ${{ inputs.region }} | ||
run: | | ||
UNTAGGED_IMAGES=$( aws ecr list-images --region ${AWS_REGION} --repository-name lambda-perf --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json ) | ||
aws ecr batch-delete-image --region ${AWS_REGION} --repository-name lambda-perf --image-ids "$UNTAGGED_IMAGES" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: build and upload artifacts in S3 | ||
name: AWS publish artifacts to S3 | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
mfaCode: | ||
type: string | ||
description: MFA Code | ||
required: true | ||
region: | ||
description: 'region on which you want to deploy' | ||
type: choice | ||
|
@@ -27,6 +27,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
outputs: | ||
runner: ${{ steps.select.outputs.runner }} | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Check branch | ||
id: select | ||
|
@@ -37,11 +38,27 @@ jobs: | |
echo "runner=self-hosted" >> $GITHUB_OUTPUT | ||
fi | ||
cat $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
- name: Build runtime matrix | ||
id: set-matrix | ||
run: | | ||
jq -c '[.runtimes[] | select(.architectures | index("${{ inputs.architecture }}")) | .path]' manifest.json | ||
echo "matrix=$(jq -c '[.runtimes[] | select(.architectures | index("${{ inputs.architecture }}")) | .path]' manifest.json)" >> $GITHUB_OUTPUT | ||
build-upload: | ||
needs: setup | ||
runs-on: ${{ needs.setup.outputs.runner }} | ||
strategy: | ||
matrix: | ||
runtime_id: ${{fromJson(needs.setup.outputs.matrix)}} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: configure aws credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | ||
role-session-name: GitHub_Action_LambdaPerf_Session | ||
aws-region: ${{ inputs.region }} | ||
- name: Delete huge unnecessary folders | ||
run: | | ||
rm -rf /opt/hostedtoolcache | ||
|
@@ -52,15 +69,8 @@ jobs: | |
env: | ||
ARCHITECTURE: ${{ inputs.architecture }} | ||
AWS_REGION: ${{ inputs.region }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.RESTRICTED_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.RESTRICTED_AWS_SECRET_ACCESS_KEY }} | ||
AWS_MFA_ARN: ${{ secrets.RESTRICTED_AWS_MFA_ARN }} | ||
RUNTIME_ID: ${{ matrix.runtime_id }} | ||
run: | | ||
creds_json=$(aws sts get-session-token --serial-number ${AWS_MFA_ARN} --token-code ${{ inputs.mfaCode }}) | ||
export AWS_ACCESS_KEY_ID=$(echo "$creds_json" | jq .Credentials.AccessKeyId |tr -d '"') | ||
export AWS_SECRET_ACCESS_KEY=$(echo "$creds_json" | jq .Credentials.SecretAccessKey| tr -d '"') | ||
export AWS_SESSION_TOKEN=$(echo "$creds_json" | jq .Credentials.SessionToken|tr -d '"') | ||
cd s3-uploader | ||
yarn install | ||
node app.mjs | ||
node app.mjs |
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
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