-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e673b70
commit 6846aa6
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# amplify-preview-actions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |