Skip to content

Commit

Permalink
implement eks deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 committed Feb 10, 2024
1 parent ee3629c commit c2ef456
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions .github/workflows/deploy-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ on:
types: [ "trigger_deploy_release_event" ]

env:
AWS_REGION: us-west-2 # set this to your preferred AWS region, e.g. us-west-1\ # file, e.g. .aws/task-definition.json
CONTAINER_NAME: MY_CONTAINER_NAME # set this to the name of the container in the
# containerDefinitions section of your task definition
AWS_REGION: us-west-2 # set this to your preferred AWS region, e.g. us-west-1

permissions:
contents: read
Expand All @@ -61,41 +59,38 @@ jobs:
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4.0.1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 8: third-party GitHubAction not pinned by hash
Click Remediation section below to solve this issue
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# - name: Configure kubectl using Action
# uses: actions-hub/kubectl@master
# env:
# KUBE_CONFIG: ${{ secrets.KUBECONFIG }}

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
- name: Configure kubectl via Secret Env
env:
KUBE_CONFIG: ${{ secrets.KUBECONFIG }}
run: |
echo $KUBE_CONFIG > ${{ github.workspace }}/kubeconfig
export KUBECONFIG=${{ github.workspace }}/kubeconfig
kubectl config get-contexts
kubectl config use-context eks-uswest2-cluster
kubectl version
- name: Install AWS CLI
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version
- name: Deploy to EKS
shell: pwsh
run: ${{ github.workspace }}/scripts/deploy.ps1



- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true

0 comments on commit c2ef456

Please sign in to comment.