34
34
deploy-sar-app :
35
35
runs-on : ubuntu-latest
36
36
environment : ${{ inputs.environment }}
37
+ strategy :
38
+ matrix :
39
+ architecture : ["x86_64", "arm64"]
37
40
steps :
38
41
- name : Checkout
39
42
uses : actions/checkout@v3
@@ -63,46 +66,39 @@ jobs:
63
66
- name : Unzip artefact
64
67
run : |
65
68
unzip cdk.out.zip
66
- - name : Set test SAR name
69
+ - name : Set SAR name
67
70
run : |
68
71
NAME=${{ env.SAR_NAME }}
69
72
if [[ "${{ inputs.stage }}" == "BETA" ]]; then
70
73
NAME="test-$NAME"
71
74
fi
72
75
echo SAR_NAME="${NAME}" >> "$GITHUB_ENV"
73
- - name : Deploy x86_64 SAR
76
+ - name : Adds arm64 suffix to SAR name
77
+ if : ${{ matrix.architecture == 'arm64' }}
78
+ run : echo SAR_NAME="${SAR_NAME}-arm64" >> "$GITHUB_ENV"
79
+ - name : Deploy SAR
74
80
run : |
75
- asset=$(jq -jc '.Resources[] | select(.Properties.CompatibleArchitectures == ["x86_64 "]) | .Metadata."aws:asset:path"' cdk.out/LayerV2Stack.template.json)
81
+ asset=$(jq -jc '.Resources[] | select(.Properties.CompatibleArchitectures == ["${{ matrix.architecture }} "]) | .Metadata."aws:asset:path"' cdk.out/LayerV2Stack.template.json)
76
82
sed -e "s|<VERSION>|${{ inputs.package-version }}|g" -e "s/<SAR_APP_NAME>/${{ env.SAR_NAME }}/g" -e "s|<LAYER_CONTENT_PATH>|./cdk.out/$asset|g" layer/sar/template.txt > template.yml
77
83
cp README.md LICENSE "./cdk.out/$asset/"
78
84
sam package --template-file template.yml --output-template-file packaged.yml --s3-bucket ${{ secrets.AWS_SAR_S3_BUCKET }}
79
85
sam publish --template packaged.yml --region "$AWS_REGION"
80
- - name : Publish x86_64 SAR
86
+ - name : Publish SAR
81
87
if : ${{ inputs.stage == 'PROD' }}
82
88
run : |
83
89
# wait until sar registers the app, otherwise it fails to make it public
84
90
sleep 15
85
- echo "Make x86_64 SAR app public"
91
+ echo "Make SAR app public"
86
92
aws serverlessrepo put-application-policy --application-id arn:aws:serverlessrepo:${{ env.AWS_REGION }}:${{ steps.aws-credentials-sar-role.outputs.aws-account-id }}:applications/${{ env.SAR_NAME }} --statements Principals='*',Actions=Deploy
87
- - name : Deploy arm64 SAR
88
- run : |
89
- asset=$(jq -jc '.Resources[] | select(.Properties.CompatibleArchitectures == ["arm64"]) | .Metadata."aws:asset:path"' cdk.out/LayerV2Stack.template.json)
90
- sed -e "s|<VERSION>|${{ inputs.package-version }}|g" -e "s/<SAR_APP_NAME>/${{ env.SAR_NAME }}-arm64/g" -e "s|<LAYER_CONTENT_PATH>|./cdk.out/$asset|g" layer/sar/template.txt > template.yml
91
- cp README.md LICENSE "./cdk.out/$asset/"
92
- sam package --template-file template.yml --output-template-file packaged.yml --s3-bucket ${{ secrets.AWS_SAR_S3_BUCKET }}
93
- sam publish --template packaged.yml --region "$AWS_REGION"
94
- - name : Publish arm64 SAR
95
- if : ${{ inputs.stage == 'PROD' }}
96
- run : |
97
- # wait until sar registers the app, otherwise it fails to make it public
98
- sleep 15
99
- echo "Make arm64 SAR app public"
100
- aws serverlessrepo put-application-policy --application-id arn:aws:serverlessrepo:${{ env.AWS_REGION }}:${{ steps.aws-credentials-sar-role.outputs.aws-account-id }}:applications/${{ env.SAR_NAME }}-arm64 --statements Principals='*',Actions=Deploy
101
93
- name : Deploy BETA canary
102
94
if : ${{ inputs.stage == 'BETA' }}
103
95
run : |
104
96
STACK_NAME=serverlessrepo-v2-powertools-layer-test-stack
105
97
98
+ if [[ "${{ matrix.architecture }}" == "arm64" ]]; then
99
+ STACK_NAME="${STACK_NAME}-arm64"
100
+ fi
101
+
106
102
echo "Check if stack does not exist"
107
103
stack_exists=$(aws cloudformation list-stacks --query "StackSummaries[?(StackName == '$STACK_NAME' && StackStatus == 'CREATE_COMPLETE')].{StackId:StackId, StackName:StackName, CreationTime:CreationTime, StackStatus:StackStatus}" --output text)
108
104
echo "$stack_exists"
@@ -128,19 +124,11 @@ jobs:
128
124
exit 1
129
125
fi
130
126
echo "Deployment successful"
131
- - name : Cleanup BETA x86_64 SAR
127
+ - name : Cleanup BETA SAR
132
128
if : ${{ inputs.stage == 'BETA' }}
133
129
run : |
134
130
app_id=$(aws serverlessrepo list-applications --output text --query "Applications[?ApplicationId=='arn:aws:serverlessrepo:${{ env.AWS_REGION }}:${{ steps.aws-credentials-sar-role.outputs.aws-account-id }}:applications/${{ env.SAR_NAME }}'].ApplicationId")
135
131
if [ -z "${app_id}" ]; then
136
132
echo "Could not find the SAR that we just deployed."
137
133
fi
138
134
aws serverlessrepo delete-application --application-id "$app_id"
139
- - name : Cleanup BETA arm64 SAR
140
- if : ${{ inputs.stage == 'BETA' }}
141
- run : |
142
- app_id=$(aws serverlessrepo list-applications --output text --query "Applications[?ApplicationId=='arn:aws:serverlessrepo:${{ env.AWS_REGION }}:${{ steps.aws-credentials-sar-role.outputs.aws-account-id }}:applications/${{ env.SAR_NAME }}-arm64'].ApplicationId")
143
- if [ -z "${app_id}" ]; then
144
- echo "Could not find the SAR that we just deployed."
145
- fi
146
- aws serverlessrepo delete-application --application-id "$app_id"
0 commit comments