Automating Deployment with GitHub Actions

Create a GitHub workflow to automate frontend deployment on AWS S3 bucket.

We'll cover the following

Earlier we explored how GitHub Actions make the flow of deployment easier, more secure, and more reliable for developers. That is why, in this lesson, we are also using GitHub Actions to automate the deployment of the React application.

There is a GitHub action for AWS called configure-aws-credentials. We will use this action to configure AWS credentials in the workflow to execute a command to upload the content of the build folder in the S3 bucket created earlier. But before that, we will follow the same workflow of CI/CD:

  1. Install the dependencies of the project.

  2. Run tests to make sure the application won’t break in production and to ensure there areno regressions.

  3. Run the build command to have a production-ready application.

  4. Deploy on AWS S3.

Let’s add a new workflow file in the repository for the deployment of the React application.

Note: For this course, the Django application and the React application are in the same repository. This choice was made to make it easier for you to go through the code and the project. This means you will find two workflows in the .github/workflows directory. If you have split the code of the Django application and the React project into different repositories, make sure to not mix the GitHub Actions files.

Writing the workflow file

Inside the .github/workflows directory, create a file called deploy-frontend.yml. As usual, the first step when writing a GitHub Actions file is to define the name of the workflow and the condition that will trigger this workflow:

Get hands-on with 1200+ tech skills courses.