Skip to content

Commit 00f9489

Browse files
authored
Rename spa to site (#8)
* Changing SPA to site * Changing 0.1.5 to 0.2.0 * Adding small dep * Length fix, bumping aws_auth * Adding sleep * Final touch
1 parent 6ece983 commit 00f9489

File tree

6 files changed

+123
-102
lines changed

6 files changed

+123
-102
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ graph TD;
2121
3. If domain and cert wanted, registered domain in AWS.
2222

2323
### 1. Files to publish
24-
Will grab everything defined in `aws_spa_source_folder` and push it to a bucket.
24+
Will grab everything defined in `aws_site_source_folder` and push it to a bucket.
2525

26-
Define `aws_spa_root_object` if different than `index.html`.
26+
Define `aws_site_root_object` if different than `index.html`.
2727

2828
### 2. An AWS account
2929
You'll need [Access Keys](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-appendix-sign-up.html) from an [AWS account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/)
@@ -49,12 +49,12 @@ on:
4949
branches: [ main ]
5050

5151
jobs:
52-
Deploy-SPA:
52+
Deploy-static-site:
5353
runs-on: ubuntu-latest
5454

5555
steps:
5656
- name: Create deploy-bucket
57-
uses: bitovi/github-actions-deploy-static-site-to-aws@v0.1.5
57+
uses: bitovi/github-actions-deploy-static-site-to-aws@v0.2.0
5858
with:
5959
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
6060
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -63,10 +63,10 @@ jobs:
6363
tf_action: 'apply'
6464
tf_state_bucket_destroy: true # If destroying, will remove the bucket
6565

66-
aws_spa_cdn_enabled: true
66+
aws_site_cdn_enabled: true
6767

6868
aws_r53_domain_name: example.com # You should own and have this domain available in R53
69-
aws_r53_sub_domain_name: spa
69+
aws_r53_sub_domain_name: site
7070
aws_r53_create_sub_cert: true # Will create and validate a cert for this sub-domain
7171
```
7272
@@ -76,7 +76,7 @@ jobs:
7676
1. [Action defaults](#action-defaults-inputs)
7777
1. [AWS](#aws-inputs)
7878
1. [Terraform options](#terraform-options-inputs)
79-
1. [SPA Settings](#spa-settings-inputs)
79+
1. [SITE Settings](#site-settings-inputs)
8080
1. [Certificate](#certificate-inputs)
8181
8282
The following inputs can be used as `step.with` keys
@@ -111,21 +111,21 @@ The following inputs can be used as `step.with` keys
111111
<hr/>
112112
<br/>
113113

114-
#### **SPA Settings inputs**
114+
#### **Site Settings inputs**
115115
| Name | Type | Description |
116116
|------------------|---------|------------------------------------|
117-
| `aws_spa_source_folder` | String | Source folder for files to be published. Will ignore any hidden file. Defaults to root folder of the calling repo if nothing defined. |
118-
| `aws_spa_root_object` | Boolean | Root object to be served as entry-point. Defaults to `index.html`. |
119-
| `aws_spa_website_bucket_name` | String | AWS S3 bucket name to use for the public files. Defaults to `${org}-${repo}-{branch}-sp`. If using a R53 domain and not a CDN, bucket name will be the FQDN one. See note. |
120-
| `aws_spa_cdn_enabled` | Boolean | Enable or disables the use of CDN. Defaults to `false`. |
117+
| `aws_site_source_folder` | String | Source folder for files to be published. Will ignore any hidden file. Defaults to root folder of the calling repo if nothing defined. |
118+
| `aws_site_root_object` | Boolean | Root object to be served as entry-point. Defaults to `index.html`. |
119+
| `aws_site_bucket_name` | String | AWS S3 bucket name to use for the public files. Defaults to `${org}-${repo}-{branch}-sp`. If using a R53 domain and not a CDN, bucket name will be the FQDN one. See note. |
120+
| `aws_site_cdn_enabled` | Boolean | Enable or disables the use of CDN. Defaults to `false`. |
121121
<hr/>
122122
<br/>
123123

124124
#### **Certificate Inputs**
125125
| Name | Type | Description |
126126
|------------------|---------|------------------------------------|
127127
| `aws_r53_domain_name` | String | Define the root domain name for the application. e.g. `bitovi.com`. |
128-
| `aws_r53_sub_domain_name` | String | Define the sub-domain part of the URL. Defaults to `${GITHUB_ORG_NAME}-${GITHUB_REPO_NAME}-${GITHUB_BRANCH_NAME}`. |
128+
| `aws_r53_sub_domain_name` | String | Define the sub-domain part of the URL. Defaults to `${GITHUB_ORG_NAME}-${GITHUB_REPO_NAME}-${GITHUB_BRANCH_NAME}`. If longer than 63, will use a shorter version. |
129129
| `aws_r53_root_domain_deploy` | Boolean | Deploy application to root domain. Will create root and www records. Default is `false`. |
130130
| `aws_r53_cert_arn` | String | Define the certificate ARN to use for the application. |
131131
| `aws_r53_create_root_cert` | Boolean | Generates and manage the root cert for the application. Default is `false`. |
@@ -147,7 +147,7 @@ For some specific resources, we have a 32 characters limit. If the identifier le
147147

148148
As a default, the bucket name will be `${GITHUB_ORG_NAME}-${GITHUB_REPO_NAME}-${GITHUB_BRANCH_NAME}-sp`.
149149

150-
But, in the case you add a Route53 domain and no CDN, the bucket name must match the FQDN defined, like `spa.example.com`. If setting `aws_r53_root_domain_deploy`, two buckets will be created. `www.{aws_r53_domain_name}`and `{aws_r53_domain_name}`. Traffic from www bucket will be forwarded to the main bucket.
150+
But, in the case you add a Route53 domain and no CDN, the bucket name must match the FQDN defined, like `site.example.com`. If setting `aws_r53_root_domain_deploy`, two buckets will be created. `www.{aws_r53_domain_name}`and `{aws_r53_domain_name}`. Traffic from www bucket will be forwarded to the main bucket.
151151
Because of this reason, the length of the FQDN *MUST* be below 64 characters. Will try using the provided FQDN, if not, fallback to `resource-identifier.{aws_r53_domain_name}` of the compressed one. IF it still exceeds the limit, will remove as many as needed.
152152

153153
> :warning: HTTPS (TLS / SSL) will only be available if using CDN.

action.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ inputs:
4242
description: 'Force purge and deletion of S3 bucket defined if terraform destroy action succeded.'
4343
required: false
4444

45-
# SPA Settings
46-
aws_spa_source_folder:
45+
# Site Settings
46+
aws_site_source_folder:
4747
description: 'Source folder for files to be published. Will ignore any hidden file. Defaults to root folder of the calling repo if nothing defined.'
4848
required: true
49-
aws_spa_root_object:
49+
aws_site_root_object:
5050
description: 'Root object to be served as entry-point. Defaults to `index.html`'
5151
required: false
52-
aws_spa_website_bucket_name:
52+
aws_site_bucket_name:
5353
description: ' AWS S3 bucket name to use for the public files. Defaults to `${org}-${repo}-{branch}-sp`'
5454
required: false
55-
aws_spa_cdn_enabled:
55+
aws_site_cdn_enabled:
5656
description: 'Enable or disables the use of CDN. Defaults to `false`.'
5757
required: false
5858

@@ -89,7 +89,7 @@ runs:
8989

9090
- name: Configure AWS Credentials
9191
if: ${{ inputs.aws_access_key_id != '' }}
92-
uses: aws-actions/configure-aws-credentials@v2
92+
uses: aws-actions/configure-aws-credentials@v3
9393
with:
9494
aws-access-key-id: ${{ inputs.aws_access_key_id }}
9595
aws-secret-access-key: ${{ inputs.aws_secret_access_key }}
@@ -107,11 +107,11 @@ runs:
107107
# TF
108108
TF_STATE_BUCKET: ${{ inputs.tf_state_bucket }}
109109
TF_STATE_BUCKET_DESTROY: ${{ inputs.tf_state_bucket_destroy }}
110-
# SPA
111-
AWS_SPA_SOURCE_FOLDER: ${{ inputs.aws_spa_source_folder }}
112-
AWS_SPA_ROOT_OBJECT: ${{ inputs.aws_spa_root_object }}
113-
AWS_SPA_WEBSITE_BUCKET_NAME: ${{ inputs.aws_spa_website_bucket_name }}
114-
AWS_SPA_CDN_ENABLED: ${{ inputs.aws_spa_cdn_enabled }}
110+
# Site
111+
AWS_SITE_SOURCE_FOLDER: ${{ inputs.aws_site_source_folder }}
112+
AWS_SITE_ROOT_OBJECT: ${{ inputs.aws_site_root_object }}
113+
AWS_SITE_BUCKET_NAME: ${{ inputs.aws_site_bucket_name }}
114+
AWS_SITE_CDN_ENABLED: ${{ inputs.aws_site_cdn_enabled }}
115115
# AWS Route53 Domains abd Certificates
116116
AWS_R53_DOMAIN_NAME: ${{ inputs.aws_r53_domain_name }}
117117
AWS_R53_SUB_DOMAIN_NAME: ${{ inputs.aws_r53_sub_domain_name }}

scripts/generate_deploy.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ GITHUB_IDENTIFIER_SS="$($GITHUB_ACTION_PATH/scripts/generate_identifier.sh 30)"
3434
echo "GITHUB_IDENTIFIER SS: [$GITHUB_IDENTIFIER_SS]"
3535

3636
# Moving files, excluding hidden ones.
37-
SOURCE_FILES="$GITHUB_WORKSPACE/$AWS_SPA_SOURCE_FOLDER"
37+
SOURCE_FILES="$GITHUB_WORKSPACE/$AWS_SITE_SOURCE_FOLDER"
3838
rsync -av --exclude=".*" $SOURCE_FILES/ "${GITHUB_ACTION_PATH}/upload"
3939
SOURCE_FILES="${GITHUB_ACTION_PATH}/upload"
4040

@@ -66,18 +66,23 @@ aws_r53_sub_domain_name=
6666
if [ -n "${AWS_R53_SUB_DOMAIN_NAME}" ]; then
6767
aws_r53_sub_domain_name="aws_r53_sub_domain_name = \"${AWS_R53_SUB_DOMAIN_NAME}\""
6868
else
69-
aws_r53_sub_domain_name="aws_r53_sub_domain_name = \"${GITHUB_IDENTIFIER}\""
69+
concatenated_string="${GITHUB_IDENTIFIER}.${AWS_R53_DOMAIN_NAME}"
70+
if [ ${#concatenated_string} -gt 64 ]; then
71+
aws_r53_sub_domain_name="aws_r53_sub_domain_name = \"${GITHUB_IDENTIFIER_SS}\""
72+
else
73+
aws_r53_sub_domain_name="aws_r53_sub_domain_name = \"${GITHUB_IDENTIFIER}\""
74+
fi
7075
fi
7176

7277
aws_tf_state_bucket=$(generate_var aws_tf_state_bucket $TF_STATE_BUCKET)
7378
#-- AWS Specific --#
7479
aws_additional_tags=$(generate_var aws_additional_tags $AWS_ADDITIONAL_TAGS)
7580
aws_default_region=$(generate_var aws_default_region $AWS_DEFAULT_REGION)
76-
#aws_spa_source_folder=$(generate_var aws_spa_source_folder $AWS_SPA_SOURCE_FOLDER)
77-
aws_spa_source_folder="aws_spa_source_folder = \"${SOURCE_FILES}\""
78-
aws_spa_website_bucket_name=$(generate_var aws_spa_website_bucket_name $AWS_SPA_WEBSITE_BUCKET_NAME)
79-
aws_spa_cdn_enabled=$(generate_var aws_spa_cdn_enabled $AWS_SPA_CDN_ENABLED)
80-
aws_spa_root_object=$(generate_var aws_spa_root_object $AWS_SPA_ROOT_OBJECT)
81+
#aws_site_source_folder=$(generate_var aws_site_source_folder $AWS_SITE_SOURCE_FOLDER)
82+
aws_site_source_folder="aws_site_source_folder = \"${SOURCE_FILES}\""
83+
aws_site_bucket_name=$(generate_var aws_site_bucket_name $AWS_SITE_BUCKET_NAME)
84+
aws_site_cdn_enabled=$(generate_var aws_site_cdn_enabled $AWS_SITE_CDN_ENABLED)
85+
aws_site_root_object=$(generate_var aws_site_root_object $AWS_SITE_ROOT_OBJECT)
8186
aws_r53_domain_name=$(generate_var aws_r53_domain_name $AWS_R53_DOMAIN_NAME)
8287
aws_r53_root_domain_deploy=$(generate_var aws_r53_root_domain_deploy $AWS_R53_ROOT_DOMAIN_DEPLOY)
8388
aws_r53_enable_cert=$(generate_var aws_r53_enable_cert $AWS_R53_ENABLE_CERT)
@@ -92,10 +97,10 @@ $aws_resource_identifier
9297
$aws_resource_identifier_supershort
9398
$aws_additional_tags
9499
$aws_tf_state_bucket
95-
$aws_spa_source_folder
96-
$aws_spa_website_bucket_name
97-
$aws_spa_cdn_enabled
98-
$aws_spa_root_object
100+
$aws_site_source_folder
101+
$aws_site_bucket_name
102+
$aws_site_cdn_enabled
103+
$aws_site_root_object
99104
$aws_r53_domain_name
100105
$aws_r53_sub_domain_name
101106
$aws_r53_root_domain_deploy

scripts/generate_provider.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ terraform {
2626
backend \"s3\" {
2727
region = \"${AWS_DEFAULT_REGION}\"
2828
bucket = \"${TF_STATE_BUCKET}\"
29-
key = \"tf-state-spa\"
29+
key = \"tf-state-site\"
3030
encrypt = true #AES-256encryption
3131
}
3232
}

0 commit comments

Comments
 (0)