Skip to content

Commit e9c9100

Browse files
committed
feat: add check different submodules for changes
1 parent e21d07c commit e9c9100

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

action.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,22 @@ runs:
2626
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
2727
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2828
aws-region: ${{ secrets.AWS_REGION }}
29-
- run: chmod +x ./scripts/get_env.sh && ./scripts/get_env.sh
29+
- id: get-diff
30+
name: Get different submodules
31+
run: chmod +x ./scripts/diff.sh && ./scripts/diff.sh
32+
env:
33+
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
34+
GITHUB_SHA: ${{ github.GITHUB_SHA }}
35+
outputs:
36+
submodules:
37+
description: "Submodules to be deployed"
38+
- name: Deploy to AWS
39+
run: chmod +x ./main.sh && ./scripts/main.sh ${{ steps.get-diff.outputs.submodules }}
3040
shell: bash
3141
env:
3242
GET_ENV: ${{ inputs.get-env }}
3343
ENV_BUCKET: ${{ inputs.env-bucket }}
34-
- run: chmod +x ./main.sh && ./scripts/main.sh
35-
shell: bash
36-
env:
3744
AWS_APP_NAME: ${{ inputs.aws-app-name }}
38-
APP_BUCKET: ${{ inputs.app-bucket }}
45+
AWS_PUBLISH_BUCKET_NAME: ${{ inputs.app-bucket }}
3946
AWS_FILENAME: ${{ inputs.aws-app-name }}-${{ github.sha }}
40-
AWS_GROUP: ${{ inputs.app-group }}
47+
AWS_DEPLOY_GROUP: ${{ inputs.app-group }}

scripts/diff.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
temp=("$(git diff-tree --submodule=diff --name-only ${GITHUB_EVENT_BEFORE} ${GITHUB_SHA})")
4+
5+
echo $temp
6+
7+
# Keeping only distinct values in the array
8+
UNIQ_SUBS=($(echo "${temp[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
9+
10+
echo ::set-output name=submodules::$UNIQ_SUBS

scripts/main.sh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
#!/bin/sh
22

3-
if [ ! -f "appspec.yml" ]; then
4-
echo $PWD
5-
echo "AppSpec.yml not found in project root"
6-
exit 1
7-
fi
8-
9-
sh ./push.sh
10-
sh ./deploy.sh
3+
for SUB in ${1[@]}
4+
do
5+
if [ -d "$SUB" ]
6+
then
7+
cd ${SUB}
8+
if [ ! -f "appspec.yml" ]
9+
then
10+
echo $PWD
11+
echo "AppSpec.yml not found in ${SUB}"
12+
continue
13+
fi
14+
else
15+
continue
16+
fi
17+
18+
echo "Getting ${SUB} ENV variables ....."
19+
chmod +x ./get_env.sh
20+
sh ./get_env.sh
21+
22+
echo "Pushing: ${SUB} ......"
23+
chmod +x ./push.sh
24+
sh ./push.sh
25+
26+
echo "Creating Deployment: ${SUB} ......"
27+
chmod +x ./deploy.sh
28+
sh ./deploy.sh
29+
30+
cd ..
31+
done

0 commit comments

Comments
 (0)