GitHub Actions setup
- Create a new repository on GitHub.
- Open your repository on GitHub, then click the tab labeled Settings.
- Click the section labeled Secrets and variables on the left hand side to expand it.
- Create separate staging and production GitHub environments in the Environments section.
- You can also choose to require approval before running jobs in your production environment. More information here.
- You may need to change the
environmentvariable in the jobs section of the GitHub Actions below based on the name of your GitHub environments.
- Click the link labeled Actions.
- Click the button labeled New repository secret in the top right corner.
- Follow the instructions below for your specific cloud provider:
AWS
- If you haven’t already, create a new AWS ECR repository.
- You’ll need AWS credentials with the following policy permissions:
- In the field labeled Name, enter the value
AWS_ACCESS_KEY_ID. - In the field labeled Secret, enter your AWS Access Key ID.
- Click the button labeled Add secret to save.
- Add a 2nd secret by clicking the button labeled New repository secret in the top right corner.
- In the field labeled Name, enter the value
AWS_SECRET_ACCESS_KEY. - In the field labeled Secret, enter your AWS Secret Access Key.
- Click the button labeled Add secret to save.
- Click on the tab labeled Actions.
- On the left side, click the button labeled New workflow.
- Find the link labeled
set up a workflow yourselfand click it. - Copy the contents from the GitHub Action YAML file for AWS at templates/github_actions/build_and_deploy_to_aws_ecs_staging_production.yml, and paste it into the textarea.
- Change the following values under the key labeled
env:
- Click the button labeled Start commit in the top right corner.
- Click the button labeled Commit new file.
- Every time you merge a pull request into the master branch, this GitHub Action will run, building a Docker image using your GitHub code, then updating AWS ECS to use the new image with the updated code.