Skip to content

Commit 5e76599

Browse files
Support app_directory (#22)
* Support app_directory
1 parent 301ba48 commit 5e76599

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ The following inputs can be used as `step.with` keys
7474
| `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}` |
7575
| `stack_destroy` | String | Set to `true` to destroy the stack. Default is `""` |
7676
| `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. |
77+
| `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. |
7778

7879
## Made with BitOps
7980
[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.

action.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ inputs:
4242
required: true
4343
sub_domain:
4444
description: 'Define the sub-domain part of the URL. Defaults to `${org}-${repo}-{branch}`'
45+
app_directory:
46+
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.'
4547
outputs:
4648
vm_url:
4749
description: "The URL of the generated app"
@@ -72,6 +74,7 @@ runs:
7274
DOMAIN_NAME: ${{ inputs.domain_name }}
7375
SUB_DOMAIN: ${{ inputs.sub_domain }}
7476
BITOPS_FAST_FAIL: true
77+
APP_DIRECTORY: ${{ inputs.app_directory }}
7578
run: |
7679
echo "running operations/_scripts/deploy/deploy.sh"
7780
$GITHUB_ACTION_PATH/operations/_scripts/deploy/deploy.sh

operations/_scripts/generate/generate_app_repo.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ GITHUB_REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
88

99
echo "Copying files from GITHUB_WORKSPACE ($GITHUB_WORKSPACE) to ops repo's Ansible deployment (${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME})"
1010
mkdir -p "${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME}"
11-
cp -rf "$GITHUB_WORKSPACE"/* "${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME}/"
11+
12+
TARGET_PATH="$GITHUB_WORKSPACE"
13+
if [ -n "$APP_DIRECTORY" ]; then
14+
echo "APP_DIRECTORY: $APP_DIRECTORY"
15+
TARGET_PATH="${TARGET_PATH}/${APP_DIRECTORY}"
16+
fi
17+
18+
cp -rf "$TARGET_PATH"/* "${GITHUB_ACTION_PATH}/operations/deployment/ansible/app/${GITHUB_REPO_NAME}/"

operations/deployment/terraform/bitops.before-deploy.d/create-tf-state-bucket.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
echo ""
2+
echo "Creating TF_STATE_BUCKET: $TF_STATE_BUCKET"
33
if [ "$AWS_DEFAULT_REGION" == "us-east-1" ]; then
44
aws s3api create-bucket --bucket $TF_STATE_BUCKET --region $AWS_DEFAULT_REGION || true
55
else

0 commit comments

Comments
 (0)