Skip to content

Commit 9d6177c

Browse files
committed
chore: parallelize SAR
1 parent 226242f commit 9d6177c

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

.github/workflows/reusable_deploy_v2_sar.yml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
deploy-sar-app:
3535
runs-on: ubuntu-latest
3636
environment: ${{ inputs.environment }}
37+
strategy:
38+
matrix:
39+
architecture: ["x86_64", "arm64"]
3740
steps:
3841
- name: Checkout
3942
uses: actions/checkout@v3
@@ -63,46 +66,39 @@ jobs:
6366
- name: Unzip artefact
6467
run: |
6568
unzip cdk.out.zip
66-
- name: Set test SAR name
69+
- name: Set SAR name
6770
run: |
6871
NAME=${{ env.SAR_NAME }}
6972
if [[ "${{ inputs.stage }}" == "BETA" ]]; then
7073
NAME="test-$NAME"
7174
fi
7275
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
7480
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)
7682
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
7783
cp README.md LICENSE "./cdk.out/$asset/"
7884
sam package --template-file template.yml --output-template-file packaged.yml --s3-bucket ${{ secrets.AWS_SAR_S3_BUCKET }}
7985
sam publish --template packaged.yml --region "$AWS_REGION"
80-
- name: Publish x86_64 SAR
86+
- name: Publish SAR
8187
if: ${{ inputs.stage == 'PROD' }}
8288
run: |
8389
# wait until sar registers the app, otherwise it fails to make it public
8490
sleep 15
85-
echo "Make x86_64 SAR app public"
91+
echo "Make SAR app public"
8692
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
10193
- name: Deploy BETA canary
10294
if: ${{ inputs.stage == 'BETA' }}
10395
run: |
10496
STACK_NAME=serverlessrepo-v2-powertools-layer-test-stack
10597
98+
if [[ "${{ matrix.architecture }}" == "arm64" ]]; then
99+
STACK_NAME="${STACK_NAME}-arm64"
100+
fi
101+
106102
echo "Check if stack does not exist"
107103
stack_exists=$(aws cloudformation list-stacks --query "StackSummaries[?(StackName == '$STACK_NAME' && StackStatus == 'CREATE_COMPLETE')].{StackId:StackId, StackName:StackName, CreationTime:CreationTime, StackStatus:StackStatus}" --output text)
108104
echo "$stack_exists"
@@ -128,19 +124,11 @@ jobs:
128124
exit 1
129125
fi
130126
echo "Deployment successful"
131-
- name: Cleanup BETA x86_64 SAR
127+
- name: Cleanup BETA SAR
132128
if: ${{ inputs.stage == 'BETA' }}
133129
run: |
134130
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")
135131
if [ -z "${app_id}" ]; then
136132
echo "Could not find the SAR that we just deployed."
137133
fi
138134
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

Comments
 (0)