Skip to content

Commit

Permalink
feat: add check different submodules for changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShauryaAg committed Oct 23, 2021
1 parent e21d07c commit e9c9100
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
19 changes: 13 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ runs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- run: chmod +x ./scripts/get_env.sh && ./scripts/get_env.sh
- id: get-diff
name: Get different submodules
run: chmod +x ./scripts/diff.sh && ./scripts/diff.sh
env:
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
GITHUB_SHA: ${{ github.GITHUB_SHA }}
outputs:
submodules:
description: "Submodules to be deployed"
- name: Deploy to AWS
run: chmod +x ./main.sh && ./scripts/main.sh ${{ steps.get-diff.outputs.submodules }}
shell: bash
env:
GET_ENV: ${{ inputs.get-env }}
ENV_BUCKET: ${{ inputs.env-bucket }}
- run: chmod +x ./main.sh && ./scripts/main.sh
shell: bash
env:
AWS_APP_NAME: ${{ inputs.aws-app-name }}
APP_BUCKET: ${{ inputs.app-bucket }}
AWS_PUBLISH_BUCKET_NAME: ${{ inputs.app-bucket }}
AWS_FILENAME: ${{ inputs.aws-app-name }}-${{ github.sha }}
AWS_GROUP: ${{ inputs.app-group }}
AWS_DEPLOY_GROUP: ${{ inputs.app-group }}
10 changes: 10 additions & 0 deletions scripts/diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

temp=("$(git diff-tree --submodule=diff --name-only ${GITHUB_EVENT_BEFORE} ${GITHUB_SHA})")

echo $temp

# Keeping only distinct values in the array
UNIQ_SUBS=($(echo "${temp[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))

echo ::set-output name=submodules::$UNIQ_SUBS
37 changes: 29 additions & 8 deletions scripts/main.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
#!/bin/sh

if [ ! -f "appspec.yml" ]; then
echo $PWD
echo "AppSpec.yml not found in project root"
exit 1
fi

sh ./push.sh
sh ./deploy.sh
for SUB in ${1[@]}
do
if [ -d "$SUB" ]
then
cd ${SUB}
if [ ! -f "appspec.yml" ]
then
echo $PWD
echo "AppSpec.yml not found in ${SUB}"
continue
fi
else
continue
fi

echo "Getting ${SUB} ENV variables ....."
chmod +x ./get_env.sh
sh ./get_env.sh

echo "Pushing: ${SUB} ......"
chmod +x ./push.sh
sh ./push.sh

echo "Creating Deployment: ${SUB} ......"
chmod +x ./deploy.sh
sh ./deploy.sh

cd ..
done

0 comments on commit e9c9100

Please sign in to comment.