Skip to content

Support app_directory #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ The following inputs can be used as `step.with` keys
| `ec2_instance_profile` | String | The AWS IAM instance profile to use for the EC2 instance. Default is `${GITHUB_ORG_NAME}-${GITHUB_REPO_NAME}-${GITHUB_BRANCH_NAME}` |
| `stack_destroy` | String | Set to `true` to destroy the stack. Default is `""` |
| `aws_resource_identifier` | String | Set to override the AWS resource identifier for the deployment. Defaults to `${org}-{repo}-{branch}`. Use with destroy to destroy specific resources. |
| `app_directory` | String | Relative path for the directory of the app (i.e. where `Dockerfile` and `docker-compose.yaml` files are located). This is the directory that is copied to the EC2 instance. Default is the root of the repo. |

## Made with BitOps
[BitOps](https://bitops.sh) allows you to define Infrastructure-as-Code for multiple tools in a central place. This action uses a BitOps [Operations Repository](https://bitops.sh/operations-repo-structure/) to set up the necessary Terraform and Ansible to create infrastructure and deploy to it.
Expand Down
3 changes: 3 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ inputs:
required: true
sub_domain:
description: 'Define the sub-domain part of the URL. Defaults to `${org}-${repo}-{branch}`'
app_directory:
description: 'Relative path for the directory of the app (i.e. where `Dockerfile` and `docker-compose.yaml` files are located). This is the directory that is copied to the EC2 instance. Default is the root of the repo.'
outputs:
vm_url:
description: "The URL of the generated app"
Expand Down Expand Up @@ -72,6 +74,7 @@ runs:
DOMAIN_NAME: ${{ inputs.domain_name }}
SUB_DOMAIN: ${{ inputs.sub_domain }}
BITOPS_FAST_FAIL: true
APP_DIRECTORY: ${{ inputs.app_directory }}
run: |
echo "running operations/_scripts/deploy/deploy.sh"
$GITHUB_ACTION_PATH/operations/_scripts/deploy/deploy.sh
9 changes: 8 additions & 1 deletion operations/_scripts/generate/generate_app_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ GITHUB_REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')

echo "Copying files from GITHUB_WORKSPACE ($GITHUB_WORKSPACE) to ops repo's Ansible deployment (${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME})"
mkdir -p "${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME}"
cp -rf "$GITHUB_WORKSPACE"/* "${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME}/"

TARGET_PATH="$GITHUB_WORKSPACE"
if [ -n "$APP_DIRECTORY" ]; then
echo "APP_DIRECTORY: $APP_DIRECTORY"
TARGET_PATH="${TARGET_PATH}/${APP_DIRECTORY}"
fi

cp -rf "$TARGET_PATH"/* "${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME}/"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
echo ""
echo "Creating TF_STATE_BUCKET: $TF_STATE_BUCKET"
if [ "$AWS_DEFAULT_REGION" == "us-east-1" ]; then
aws s3api create-bucket --bucket $TF_STATE_BUCKET --region $AWS_DEFAULT_REGION || true
else
Expand Down