Example GitHub Actions workflow to deploy to Amazon EKS
An example workflow that uses GitHub Actions to build a static website into a container image tagged with the git sha, push that image to Amazon Elastic Container Registry, and deploy to Amazon EKS using a simple Kubernetes Deployment and Service yaml with the image tag injected by Kustomize.
Prerequisites
- Create an EKS cluster, e.g. using
eksctl create cluster
- Create an ECR repo called
example-eks
Secrets
The following secrets are required to be set on the repository:
AWS_ACCESS_KEY_ID
: An AWS access key ID for an account having the EKS IAM roleAWS_SECRET_ACCESS_KEY
: An AWS secret sccess key for an account having the EKS IAM role
Env vars
The following environment variables need to be set in the workflow:
- AWS_REGION: (e.g. eu-west-1)
- EKS_CLUSTER_NAME: (e.g. exciting-party-1574475054)
You can optionally change the name of the ECR repo mentioned above in prereqs.
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: example-eks
IMAGE_TAG: ${{ github.sha }}
Contributions
We welcome contributions! See how to contribute.