Skip to content

Commit

Permalink
add amplify commands
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlinchen committed Sep 10, 2020
1 parent f54acfa commit c1bef10
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
echo "##[set-output name=setbranchname;]$(echo ${GITHUB_HEAD_REF//[-_]/} | cut -c-10)"
- name: deploy PR preview
uses: yinlinchen/amplify-preview-actions@0.1
uses: yinlinchen/amplify-preview-actions@0.2
with:
branch_name: ${{ steps.setenvname.outputs.setbranchname }}
aws_cli_version: '1.18.135'
amplify_command: deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ inputs:
branch_name:
description: 'GitHub branch name to deploy'
required: true
aws_cli_version:
description: 'version of AWS Cli to use'
required: false
amplify_command:
description: 'amplify command: SUPPORTED: [deploy, delete]'
required: true

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.branch_name }}
- ${{ inputs.aws_cli_version }}
- ${{ inputs.amplify_command }}
branding:
icon: 'git-commit'
color: 'blue'
26 changes: 23 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,39 @@ if [ -z "$1" ] ; then
exit 1
fi

if [ -z "$2" ] ; then
echo "You must provide amplify_command input parameter in order to deploy"
exit 1
fi

aws configure --profile amplify-preview-actions <<-EOF > /dev/null 2>&1
${AWS_ACCESS_KEY_ID}
${AWS_SECRET_ACCESS_KEY}
${AWS_REGION}
text
EOF

sh -c "aws amplify create-branch --app-id=${AmplifyAppId} --branch-name=$1 \
case $2 in

deploy)
sh -c "aws amplify create-branch --app-id=${AmplifyAppId} --branch-name=$1 \
--backend-environment-arn=${BackendEnvARN} --region=${AWS_REGION}"

sleep 10
sleep 10

sh -c "aws amplify start-job --app-id=${AmplifyAppId} --branch-name=$1 --job-type=RELEASE --region=${AWS_REGION}"
;;

delete)
sh -c "aws amplify delete-branch --app-id=${AmplifyAppId} --branch-name=$1 --region=${AWS_REGION}"
;;

*)
echo "amplify command $2 is invalid or not supported"
exit 1
;;

sh -c "aws amplify start-job --app-id=${AmplifyAppId} --branch-name=$1 --job-type=RELEASE --region=${AWS_REGION}"
esac

aws configure --profile amplify-preview-actions <<-EOF > /dev/null 2>&1
null
Expand Down

0 comments on commit c1bef10

Please sign in to comment.