diff --git a/aws-amplify-deployment/action.sh b/aws-amplify-deployment/action.sh new file mode 100755 index 0000000..7119f73 --- /dev/null +++ b/aws-amplify-deployment/action.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# set amplify branch from git branch if not defined +if [ -z "$AMPLIFY_BRANCH" ]; then + AMPLIFY_BRANCH=$(basename $GITHUB_REF) +fi + +# source url +if [ -z "$AMPLIFY_SOURCE_URL" ]; then + AMPLIFY_SOURCE_URL="$AMPLIFY_BUCKET/$GITHUB_REPOSITORY/$AMPLIFY_BRANCH/$GITHUB_SHA.zip" +fi + +cd $AMPLIFY_DIST_PATH +zip -r $GITHUB_SHA.zip * +aws s3 cp $GITHUB_SHA.zip $AMPLIFY_SOURCE_URL + +aws amplify start-deployment --app-id $AMPLIFY_APP_ID --branch-name $AMPLIFY_BRANCH --source-url $AMPLIFY_SOURCE_URL diff --git a/aws-amplify-deployment/action.yml b/aws-amplify-deployment/action.yml new file mode 100644 index 0000000..e2e0eda --- /dev/null +++ b/aws-amplify-deployment/action.yml @@ -0,0 +1,29 @@ +name: 'aws-amplify-deployment' +description: 'Deploys your AWS Amplify project using GitHub Actions.' +branding: + icon: 'cloud' + color: 'orange' +inputs: + amplify-app-id: + description: 'The unique ID for an Amplify app.' + required: true + amplify-bucket: + description: 'The artifacts S3 bucket.' + required: true + amplify-branch: + description: 'The name for the branch, for the job.' + required: false + amplify-dist-path: + description: 'Application build path.' + required: false + default: './public' +runs: + using: "composite" + steps: + - run: ${{ github.action_path }}/action.sh + shell: bash + env: + AMPLIFY_APP_ID: ${{ inputs.amplify-app-id }} + AMPLIFY_BUCKET: ${{ inputs.amplify-bucket }} + AMPLIFY_BRANCH: ${{ inputs.amplify-branch }} + AMPLIFY_DIST_PATH: ${{ inputs.amplify-dist-path }}