11name : Deploy API Lambda
2+
23on :
3- push :
4- branches :
5- - main
6- workflow_dispatch :
4+ workflow_call :
5+ inputs :
6+ environment :
7+ required : true
8+ type : string
9+ description : edge, staging or prod
10+ ref :
11+ required : false
12+ type : string
13+ default : ${{ github.ref }}
714
815permissions :
916 contents : read
@@ -13,23 +20,21 @@ jobs:
1320 permissions :
1421 contents : read
1522 uses : ./.github/workflows/build-api-lambda.yml
16-
23+ with :
24+ ref : ${{ inputs.ref }}
25+
1726 deploy :
18- concurrency : ${{ github.workflow }}
27+ concurrency : ${{ github.workflow }}-${{ inputs.environment }}
1928 permissions :
2029 contents : read
2130 id-token : write
2231 runs-on : ubuntu-latest
2332 needs : build
24- environment : docs-api-edge
33+ environment : docs-api-${{ inputs.environment }}
2534 env :
2635 ZIP_FILE : api-lambda.zip
2736 steps :
2837 - uses : actions/checkout@v5
29- - name : Download bootstrap binary
30- uses : actions/download-artifact@v4
31- with :
32- name : api-lambda-binary
3338
3439 - name : Download bootstrap binary
3540 uses : actions/download-artifact@v4
@@ -40,13 +45,24 @@ jobs:
4045 run : |
4146 zip -j "${ZIP_FILE}" ./bootstrap
4247
43- - uses : aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
48+ - uses : aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0
4449 with :
45- role-to-assume : arn:aws:iam::197730964718:role/elastic-docs-v3-api-deployer-edge
50+ role-to-assume : arn:aws:iam::197730964718:role/elastic-docs-v3-api-deployer-${{ inputs.environment }}
4651 aws-region : us-east-1
4752
4853 - name : Upload Lambda function
4954 run : |
50- aws lambda update-function-code \
51- --function-name elastic-docs-v3-edge-api \
52- --zip-file "fileb://${ZIP_FILE}"
55+ NEW_VERSION=$(aws lambda update-function-code \
56+ --function-name "elastic-docs-v3-${ENVIRONMENT}-api" \
57+ --zip-file "fileb://${ZIP_FILE}" \
58+ --publish \
59+ --query 'Version' \
60+ --output text)
61+
62+ aws lambda update-alias \
63+ --function-name "elastic-docs-v3-${ENVIRONMENT}-api" \
64+ --name live \
65+ --function-version $NEW_VERSION
66+
67+ env :
68+ ENVIRONMENT : ${{ inputs.environment }}
0 commit comments