Skip to content
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

S3 deploy github action #69

Merged
merged 3 commits into from
Feb 15, 2022
Merged

Conversation

ChristopherNavo
Copy link
Contributor

@ChristopherNavo ChristopherNavo commented Feb 14, 2022

Documentation:

Closes #52

  • The contents of this PR updates the github action in the S3-deploy.yml to automatically create a S3 bucket on AWS whenever pushing a branch to development.
  • The action calls the makeReactBucket.bash script created by the devops team and utilizes an environmental variable based on the github action property, GITHUB_ACTOR that creates the requested initials based on the github username's first 4 characters. (See the Gallery and Tutorial below for details)

(User Story, Total time to complete the Sprint, and Acceptance Criteria can be found on the connected Issue)

File Locations

  • The S3-deploy.yml file can be found in the .github/workflow folder for reference
  • A new folder system called scripts for any present and future github actions scripts has been created.
  • So copies of the makeReactBucket.bash and makeReactBucket.yml files can be found in .github/scripts

    fileStructure

Time Spent on Issue:

Task Breakdown Description Approx. Time
Researching github action properties 2 hrs
Update Part 1: Change the .yml file to call the script to run successfully (hard-coded initial call) 2 hrs
Update Part 2: Create the github action property environmental variable 1 hr
Testing: Buckets are created when deployed and run the App 0.5 hrs \
Create the PR with additional information and follow-along screenshots 0.5 hrs
Frontend Team Meets (as of 2/13/2022) 2 hrs (total of all meetings)
DevOps Team Slack communication 1 hr (total)

Gallery & GitHub Action Tutorial:

The Updated S3-deploy.yml file:
(NOTE: Additional branches are added for testing purposes, but only the development branch for both push and pull_request will remain constant)

update_yml


The environment variable is created based on the github action property, GITHUB_ACTOR

pulling_characters


GITHUB_ACTOR is the github username of the working branch. The property is to take the first four characters of that username to use as the requested initials called for in the script. In the example "User" would be extracted from GITHUB_ACTOR and placed in the environment variable, ACTOR_INITIALS

github user


Further down in the file, when the makeReactBucket.bash script is ready to be run, the environment variable is called with those first four characters, along with the constant region in this case of us-west-2.

inputscript


Once you push your branch, return to github repo and click on the Actions tab then the S3-deploy action on the left, to see your build in process.
An echo statement have been provided to see your initials for the first portion of your bucket:

build_Initials_captured


Further down the build another echo statement will show your full bucket name.
NOTE: The script is written to turn any uppercase characters to lowercase for proper bucket naming conventions

build_bucket_nameID


Go to AWS to find your bucket

AWSbucket


Open your bucket to confirm the index.html and other react files have installed

index html


While on your bucket click on the Properties tab

properties


Scroll all the way to the bottom to find your Static Website Hosting link. Double Click the link or copy/paste into a new window.

Webhost


The current state of the react App should display.

ReactApp


Troubleshooting

  • Calling the script through github action should always successfully create a bucket. If you do not need one created, be sure to go to AWS , empty your bucket then delete.

Copy link
Contributor

@dansjack dansjack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action worked as described with the first 4 chars of the bucket coming from the current user's github handle.

I confirmed the site was deployed, then deleted the bucket

Copy link
Contributor

@peterTorres7 peterTorres7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The steps are easy to follow and the documentation is very clear, nicely done!

@ChristopherNavo ChristopherNavo merged commit 5b1ec08 into development Feb 15, 2022
@dansjack dansjack mentioned this pull request Feb 16, 2022
9 tasks
KristinJJ pushed a commit that referenced this pull request Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the S3 action to also create the bucket before deployment
3 participants