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

Create build-deploy-ec2.yml #546

Closed
wants to merge 10 commits into from

Conversation

paulespinosa
Copy link
Member

This initial GitHub Workflow, as a manual action, builds and uploads the Home Unite Us front-end application and back-end API web service to the EC2 instance currently used for the Home Unite Us project.

In this commit, the workflow does not cause the uploaded packages to run. That will come after testing and refining this commit.

related #465

Copy link
Member

@Joshua-Douglas Joshua-Douglas left a comment

Choose a reason for hiding this comment

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

Hey @paulespinosa,

Looks great! Have you been deploying manually up to this point? If so, I'm sure this will make your life a lot easier.

I just have a few minor comments and questions.

.github/workflows/build-deploy-ec2.yml Outdated Show resolved Hide resolved
Comment on lines 30 to 34
- name: Test with tox
working-directory: ./api
run: |
tox
Copy link
Member

Choose a reason for hiding this comment

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

Is this the successful build log? https://github.com/hackforla/HomeUniteUs/actions/runs/5651696696/job/15310200967

If so, I can't seem to find the tox step. Am I overlooking it? I'm mostly wondering because the api test cases were failing on my machine. I'd expect them to fail here to, unless I'm missing something

Copy link
Member

Choose a reason for hiding this comment

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

🤦‍♂️That link I posted was the PR build link haha.

Have you tried out the workflow and confirmed that it worked? If so, can I take a look at the deployment log?

Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

😊 Actually, I'm currently figuring out how to test it without merging to the main branch.

Copy link
Member

Choose a reason for hiding this comment

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

Have you tried out this workflow yet? It might be worth sending off a build before approving, to ensure the SSH access is working.

Do we have a development EC2 instance? If we did, then we wouldn't have to worry about breaking the current site

Copy link
Member Author

Choose a reason for hiding this comment

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

@Joshua-Douglas Yes, I've got it in a testable state and have been modifying it. You can see all of the runs in the Actions tab.

At this time, we have just one EC2 instance. It hosts the static landing page for https://homeunite.us/ and acts as the dev/test/demo host for https://dev.homeunite.us. As of this writing, it's hosting an old version of the frontend and the backend is down.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Joshua-Douglas It looks like the SSH keys aren't configured in GitHub secrets yet. We'll need to check with @tylerthome about that.

@paulespinosa
Copy link
Member Author

Hey @paulespinosa,

Looks great! Have you been deploying manually up to this point? If so, I'm sure this will make your life a lot easier.

I just have a few minor comments and questions.

As far as I can tell, we haven't been deploying code for quite a while. I think Tyler was manually doing the deployments in the past.

@Joshua-Douglas
Copy link
Member

As far as I can tell, we haven't been deploying code for quite a while. I think Tyler was manually doing the deployments in the past.

Ah, that is great to know. Thanks. Now I've got a bunch of questions about the version of our deployment and our deployment strategy. I'll ask at today's meeting!

Either way, thanks for getting this started!

@erikguntner
Copy link
Collaborator

erikguntner commented Jul 25, 2023

current working directory "/home/runner/work/HomeUniteUs/HomeUniteUs"

@paulespinosa you may need to set the working directory to app for the end to end tests in the build-deploy-app workflow.

@paulespinosa
Copy link
Member Author

current working directory "/home/runner/work/HomeUniteUs/HomeUniteUs"

@paulespinosa you may need to set the working directory to app for the end to end tests in the build-deploy-app workflow.

@erikguntner Thank you for catching that. I added it back in and it looks like its working again.

@ju1es
Copy link
Member

ju1es commented Jul 26, 2023

sweet. seeing in the build that it's failing on the service provider controller tests. I think Joshua has a PR that should fix.

I forget if we're working towards ci/cd but either way, can we update the readme with instructions for deployment.

This initial GitHub Workflow builds and uploads the Home Unite Us front-end application and back-end API web service to the EC2 instance currently used for the Home Unite Us project. 

In this commit, the workflow does not cause the uploaded packages to run. That will come after testing and refining this commit.

related #465
@paulespinosa paulespinosa force-pushed the 465-gh-workflow-build-deploy-ec2 branch from fe2de99 to ef6948e Compare July 26, 2023 14:07
@paulespinosa
Copy link
Member Author

@tylerthome For this workflow, I used the shimataro ssh key action with the following configuration:

      - name: Install SSH key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_KEY }}
          known_hosts: ${{ secrets.KNOWN_HOSTS }}

When the workflow runs, it appears that the shimataro ssh key action isn't picking up the SSH_KEY or KNOWN_HOSTS secrets. The error is "Error: Error: Input required and not supplied: key". Am I using the right variable names?

Also, it looks like we'll need to add the .env variables to GitHub secrets because the workflow runs tox as a step. When the tests runs the auth_controller.py module is loaded. This module has a top-level instantiation of a boto3 client that checks for the AWS credentials during initialization. Since the environment doesn't have the AWS credentials, the boto3 client instantiation fails causing the tests to fail.

Trying with a different name for the SSH key
Change the name of the SSH key for the app build
Refactor: two parallel jobs that build the API and APP and a deploy job that depends on both of the build steps to be successful. Uses build artifacts to move the builds to the deploy job. Added caching python and node dependencies.
Comment out running tests in order to test the deploy job
Added the homeunite.us public key
Make comment about the server's public key
Added deploy script
Added SSH key for SSH remote commands action
Use rsync to move app files
@paulespinosa
Copy link
Member Author

The workflow is being added to the PR #544 because the changes are related. This PR is being closed.

@paulespinosa paulespinosa deleted the 465-gh-workflow-build-deploy-ec2 branch August 18, 2023 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Infrastructure Changes to site technical Architecture
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants