Creating a continuous deployment pipeline with Github Actions and S3
It's common in today's development world to want a continuous deployment process for getting your code changes under version control to production for the world to see. While in an organisation or medium-larger sized team there may be some steps in between push-deploy, such as code reviews, testing, staging, quality assurance, client review etc. the basic flow can be set up quite easily.
- Create an S3 bucket in AWS.
- Create a GitHub repository for your project.
- Create a GitHub Action workflow that deploys your project to the S3 bucket.
- Configure the GitHub Action workflow with your AWS credentials.
- Push your code to the GitHub repository.
1. **Create an S3 bucket in AWS.**
To create an S3 bucket in AWS, you will need to:
- Go to the AWS Management Console.
- Click on the "S3" service.
- Click on the "Create Bucket" button.
- Enter a name for your bucket.
- Select a region for your bucket.
- Click on the "Create" button.
2. **Create a GitHub repository for your project.**
To create a GitHub repository for your project, you will need to:
- Go to the GitHub website.
- Click on the "Create Repository" button.
- Enter a name for your repository.
- Select a public or private repository.
- Click on the "Create Repository" button.
3. **Create a GitHub Action workflow that deploys your project to the S3 bucket.**
To create a GitHub Action workflow that deploys your project to the S3 bucket, you will need to:
- Go to your GitHub repository.
- Click on the "Actions" tab.
- Click on the "New workflow" button.
- Select the "AWS" template.
- Enter a name for your workflow.
- In the "Jobs" section, click on the "Add job" button.
- In the "Job name" field, enter a name for your job.
- In the "Run on" field, select the "push" event.
- In the "Steps" section, click on the "Add step" button.
- In the "Step name" field, enter a name for your step.
- In the "Action" field, select the "aws" action.
- In the "Use" field, select the "s3" operation.
- In the "Bucket" field, enter the name of your S3 bucket.
- In the "Key" field, enter the key for your object in the S3 bucket.
- In the "`Content-Type`" field, enter the content type of your object.
- In the "`Source`" field, enter the path to your source code.
- Click on the "Save" button.
4. **Configure the GitHub Action workflow with your AWS credentials.**
To configure the GitHub Action workflow with your AWS credentials, you will need to:
- Go to your GitHub repository settings.
- Click on the "Secrets" tab.
- Click on the "New secret" button.
- In the "Name" field, enter a name for your secret.
- In the "Value" field, enter your AWS access key ID and secret access key.
- Click on the "Add secret" button.
To push your code to the GitHub repository, you will need to:
- Go to your local repository.
- Run the following command:
Once you have pushed your code to the GitHub repository, the GitHub Action workflow will be triggered and your project will be deployed to the S3 bucket.
Comments
Post a Comment