1- name : API Lambda Deploy ⁁
2- on :
3- push :
4- branches :
5- - main
6- paths :
7- - api/**
8- - .github/workflows/api-deploy.yml
9- tags :
10- - ' *.*.*'
11- permissions :
12- contents : read
13-
14- jobs :
15- build-deploy :
16- environment : ${{ github.ref == 'refs/heads/main' && 'dev' || 'prod' }}
17- name : Build & Deploy 📦
18- runs-on : ubuntu-latest
19- defaults :
20- run :
21- working-directory : ./api
22-
23-
24- steps :
25- - uses : actions/checkout@v4
26- - name : Set up Python
27- uses : actions/setup-python@v4
28- with :
29- python-version : " 3.11"
30- - name : Setup AWS CLI
31- uses : aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
32- with :
33- aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
34- aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
35- aws-region : ${{ secrets.AWS_REGION }}
36- - name : Install dependencies
37- run : |
38- pip install cargo-lambda
39- cargo install sqlx-cli
40- - name : Rust Cache
41- uses : Swatinem/rust-cache@v2
42- with :
43- workspaces : |
44- api
45- - name : Build
46- run : cargo lambda build --release --output-format zip
47-
48- - name : Migrate Database
49- env :
50- DSQL_ENDPOINT : ${{ secrets.DSQL_ENDPOINT }}
51- run : |
52- token=$(aws dsql generate-db-connect-admin-auth-token --hostname $DSQL_ENDPOINT)
53- encoded_token=$(echo "$token" | jq -Rr @uri)
54- sqlx migrate run --database-url "postgresql://admin:${encoded_token}@${DSQL_ENDPOINT}/postgres?sslmode=require"
55-
56- - name : Upload to Lambda
57- run : aws lambda update-function-code --function-name kb2-lambda-function-${{ github.ref == 'refs/heads/main' && 'dev' || 'prod' }} --zip-file fileb://target/lambda/api/bootstrap.zip
1+ name : API Lambda Deploy ⁁
2+ on :
3+ push :
4+ branches :
5+ - main
6+ paths :
7+ - api/**
8+ - .github/workflows/api-deploy.yml
9+ tags :
10+ - ' *.*.*'
11+ workflow_dispatch : []
12+ permissions :
13+ contents : read
14+
15+ jobs :
16+ build-deploy :
17+ environment : ${{ github.ref == 'refs/heads/main' && 'dev' || 'prod' }}
18+ name : Build & Deploy 📦
19+ runs-on : ubuntu-latest
20+ steps :
21+ - uses : actions/checkout@v4
22+ - name : Setup AWS CLI
23+ uses : aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
24+ with :
25+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
26+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
27+ aws-region : ${{ secrets.AWS_REGION }}
28+ - name : Rust Cache
29+ uses : Swatinem/rust-cache@v2
30+ - name : Install dependencies
31+ run : |
32+ curl -fsSL https://cargo-lambda.info/install.sh | sh
33+ cargo install sqlx-cli
34+ - name : Build
35+ run : cargo lambda build --release --output-format zip -p api -p consumer
36+
37+ - name : Migrate Database
38+ env :
39+ DSQL_ENDPOINT : ${{ secrets.DSQL_ENDPOINT }}
40+ run : |
41+ cd api
42+ token=$(aws dsql generate-db-connect-admin-auth-token --hostname $DSQL_ENDPOINT)
43+ encoded_token=$(echo "$token" | jq -Rr @uri)
44+ sqlx migrate run --database-url "postgresql://admin:${encoded_token}@${DSQL_ENDPOINT}/postgres?sslmode=require"
45+ cd ..
46+
47+ - name : Upload api to Lambda
48+ run : aws lambda update-function-code --function-name kb2-lambda-function-${{ github.ref == 'refs/heads/main' && 'dev' || 'prod' }} --zip-file fileb://target/lambda/api/bootstrap.zip
49+
50+ - name : Upload consumer to Lambda
51+ run : aws lambda update-function-code --function-name kb2-lambda-consumer-${{ github.ref == 'refs/heads/main' && 'dev' || 'prod' }} --zip-file fileb://target/lambda/consumer/bootstrap.zip
0 commit comments