added CI/CD gh action #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: twoge-cicd | |
on: | |
push: | |
branches: | |
- eks | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
AWS_REGION: 'us-east-1' | |
EKS_CLUSTER_NAME: 'cpclass-eks-cluster' | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
with: | |
ref: eks | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Build & Push Docker Image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.DOCKER_USERNAME }}/twoge:latest | |
CD: | |
needs: CI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
with: | |
ref: eks | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Set up Kubectl for EKS | |
uses: aws-actions/amazon-eks-kubectl-set-context@v1 | |
with: | |
cluster-name: ${{ env.EKS_CLUSTER_NAME }} | |
region: ${{ env.AWS_REGION }} | |
- name: Deploy to EKS | |
run: | | |
kubectl apply -f k8s/ -n steve |