Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlinchen committed Sep 10, 2020
1 parent e673b70 commit 6846aa6
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.8-alpine

LABEL "com.github.actions.name"="AWS Amplify PR Previews for Public Repository"
LABEL "com.github.actions.description"="This action deploys your AWS Amplify pull request for your public repository"
LABEL "com.github.actions.icon"="git-commit"
LABEL "com.github.actions.color"="blue"

LABEL version="0.2"
LABEL "repository"="https://github.com/yinlinchen/amplify-preview-actions.git"
LABEL "homepage"="https://github.com/yinlinchen/amplify-preview-actions"
LABEL maintainer="Yinlin Chen <[email protected]>"

ENV AWSCLI_VERSION='1.18.14'

RUN pip install --quiet --no-cache-dir awscli==${AWSCLI_VERSION}

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# amplify-preview-actions

18 changes: 18 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'amplify-preview-actions'
description: 'This action builds and deploys your AWS Amplify pull request preview for public repository'
inputs:
branch_name:
description: 'GitHub branch name to deploy'
required: true
aws_cli_version:
description: 'version of AWS Cli to use'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.branch_name }}
- ${{ inputs.aws_cli_version }}
branding:
icon: 'git-commit'
color: 'blue'
48 changes: 48 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

set -e

if [ -z "$AWS_ACCESS_KEY_ID" ] && [ -z "$AWS_SECRET_ACCESS_KEY" ] ; then
echo "You must provide the action with both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables in order to deploy"
exit 1
fi

if [ -z "$AWS_REGION" ] ; then
AWS_REGION="us-east-1"
fi

if [ -z "$AmplifyAppId" ] ; then
echo "You must provide AmplifyAppId environment variable in order to deploy"
exit 1
fi

if [ -z "$BackendEnvARN" ] ; then
echo "You must provide BackendEnvARN environment variable in order to deploy"
exit 1
fi

if [ -z "$1" ] ; then
echo "You must provide branch name 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 \
--backend-environment-arn=${BackendEnvARN} --region=${AWS_REGION}"

sleep 10

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

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

0 comments on commit 6846aa6

Please sign in to comment.