Skip to content

Instantly share code, notes, and snippets.

@pahud
Last active July 24, 2023 08:20
Show Gist options
  • Star 46 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save pahud/4bdc6cde7b55c4fb8bd8c886dd57787e to your computer and use it in GitHub Desktop.
Save pahud/4bdc6cde7b55c4fb8bd8c886dd57787e to your computer and use it in GitHub Desktop.
Github Actions with Amazon EKS CI/CD
workflow "Demo workflow" {
on = "push"
resolves = ["SNS Notification"]
}
action "Build Image" {
uses = "actions/docker/cli@c08a5fc9e0286844156fefff2c141072048141f6"
runs = ["/bin/sh", "-c", "docker build -t $IMAGE_URI ."]
env = {
IMAGE_URI = "xxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/github-action-demo:latest"
}
}
action "ECR Login" {
uses = "actions/aws/cli@51b5c9b60da75d1d3f97ff91ed2e4efc19dd5474"
needs = ["Build Image"]
env = {
AWS_DEFAULT_REGION = "ap-northeast-1"
AWS_REGION = "$AWS_DEFAULT_REGION"
}
runs = ["/bin/sh", "-c", "aws ecr get-login --no-include-email | sh"]
secrets = [
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
]
}
action "Push ECR" {
uses = "actions/docker/cli@c08a5fc9e0286844156fefff2c141072048141f6"
needs = ["ECR Login"]
runs = ["/bin/sh", "-c", "docker push $IMAGE_URI"]
secrets = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]
env = {
IMAGE_URI = "xxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/github-action-demo:latest"
}
}
action "Deploy to EKS" {
uses = "actions/aws/kubectl@master"
# args = ["get all"]
args = ["apply -f app.yaml"]
needs = ["Push ECR"]
secrets = [
"KUBE_CONFIG_DATA",
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
]
env = {
AWS_DEFAULT_REGION = "ap-northeast-1"
}
}
action "Verify EKS Deployment" {
uses = "actions/aws/kubectl@master"
needs = ["Deploy to EKS"]
args = ["get all"]
secrets = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "KUBE_CONFIG_DATA"]
env = {
AWS_DEFAULT_REGION = "ap-northeast-1"
}
}
action "SNS Notification" {
uses = "actions/aws/cli@51b5c9b60da75d1d3f97ff91ed2e4efc19dd5474"
needs = ["Verify EKS Deployment"]
runs = ["/bin/sh", "-c", "aws --region ap-northeast-1 sns publish --topic-arn $SNS_TOPIC_ARN --message '[OK] Deploy completed'"]
secrets = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]
env = {
AWS_DEFAULT_REGION = "ap-northeast-1",
SNS_TOPIC_ARN = "arn:aws:sns:ap-northeast-1:xxxxxxxx:SNS2IM",
}
}
@kd0g
Copy link

kd0g commented Feb 5, 2020

fucking love this.

@Meghapath123
Copy link

How do I use this? This seems to be in a format that is not validating in Github actions. Please advice

@lferreira-sw
Copy link

How do I use this? This seems to be in a format that is not validating in Github actions. Please advice

same question here!

@ayk33
Copy link

ayk33 commented Jun 8, 2021

Yeah I don't know what the point of this is?

@abriperez
Copy link

Seems terraform code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment