Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-roper committed Mar 28, 2024
2 parents 4e8c89f + edfdce6 commit cbe4a14
Show file tree
Hide file tree
Showing 127 changed files with 8,555 additions and 15,391 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
["@babel/preset-react", {"runtime": "automatic"}]
]
}
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: {
"browser": true,
"es2021": true,
"jest": true
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:prettier/recommended'
],
parser: '@babel/eslint-parser',
plugins: ["jest"],
parserOptions: {
"ecmaVersion": "latest",
"sourceType": "module"
},
rules: {
"no-constant-condition": 0
}
}
80 changes: 80 additions & 0 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: "Terraform Apply"

on:
push:
branches:
- main

env:
TF_CLOUD_ORGANIZATION: "zwell-test"
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
BUILD_VERSION: "${{ github.sha }}"
TF_WORKSPACE: "static-hosting"
CONFIG_DIRECTORY: "./terraform/"
AWS_DEFAULT_REGION: "us-west-2"

jobs:
# builds and pushes image to ecr
terraform:
name: "Terraform Apply"
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3

# Gets the most current config (tf.plan) for org + workspace combo
- name: Upload Configuration
uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0
id: apply-upload
with:
workspace: ${{ env.TF_WORKSPACE }}
directory: ${{ env.CONFIG_DIRECTORY }}

# runs changes in terrafrom/ against current state to create a tf.plan
# tarraform plan
- name: Create Apply Run
uses: hashicorp/tfc-workflows-github/actions/create-run@v1.0.0
id: apply-run
env:
TF_VAR_image_tag: "\"${{ env.BUILD_VERSION }}\""
with:
workspace: ${{ env.TF_WORKSPACE }}
configuration_version: ${{ steps.apply-upload.outputs.configuration_version_id }}

# terraform apply the plan
- name: Apply
uses: hashicorp/tfc-workflows-github/actions/apply-run@v1.0.0
if: fromJSON(steps.apply-run.outputs.payload).data.attributes.actions.IsConfirmable
id: apply
with:
run: ${{ steps.apply-run.outputs.run_id }}
comment: "Apply Run from GitHub Actions CI ${{ github.sha }}"

# Once uplaoding current build and not squashing, move before tf apply
# bucket needs to be there first...
s3:
name: "Push to s3"
needs: terraform
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Upload assets to s3
shell: bash
run: |
aws s3 cp ./index.html s3://app2.zwellhome.com/index.html
aws s3 cp ./404.html s3://app2.zwellhome.com/404.html
52 changes: 52 additions & 0 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "tf plan"
on:
pull_request:

env:
TF_CLOUD_ORGANIZATION: "zwell-test"
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
TF_WORKSPACE: "static-hosting"
CONFIG_DIRECTORY: "./terraform/"

jobs:
# Add jobs in to run checks
# linting
# unit test

terraform:
name: "tf plan devtest"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3

# uploads/initiates a configuration in terraform
# akin to terraform init
- name: Upload Configuration
uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0
id: plan-upload
with:
workspace: ${{ env.TF_WORKSPACE }}
directory: ${{ env.CONFIG_DIRECTORY }}
speculative: true

# runs changes in terrafrom/ against current state to create a tf.plan
# tarraform plan
- name: Create Plan Run
uses: hashicorp/tfc-workflows-github/actions/create-run@v1.0.0
id: plan-run
with:
workspace: ${{ env.TF_WORKSPACE }}
configuration_version: ${{ steps.plan-upload.outputs.configuration_version_id }}
plan_only: true

# Gets the plan and logs it in pipeline for debugging
- name: Get Plan Output
uses: hashicorp/tfc-workflows-github/actions/plan-output@v1.0.0
id: plan-output
with:
plan: ${{ fromJSON(steps.plan-run.outputs.payload).data.relationships.plan.data.id }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": true
}
4 changes: 4 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html>
<p>zwell's 404</p>
</html>
71 changes: 15 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,29 @@
# Getting Started with Create React App
# Zwellhome Energy Calculator

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This repo acts as the front-end React app of the energy calculator.

## Available Scripts
## Local Development

In the project directory, you can run:
This service utilizes webpack and babel to build the static assets and host the local development server.

### `npm start`
`npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
## Building

The page will reload when you make changes.\
You may also see any lint errors in the console.
Builds React app as a single static asset to then host on any desired deliver platform.

### `npm test`
`npm run build`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
## Linting and Formatting

### `npm run build`
### ESLINT

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
Lints the codebase at `src/`

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
`npm run lint` or `npm run lint:fix` to apply changes if possible.

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### PRETTIER

### `npm run eject`
Formats the code

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
`npm run format`
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html>
<p>Welcome to dev.app.zwell.com</p>
</html>
Loading

0 comments on commit cbe4a14

Please sign in to comment.