build workflow

This commit is contained in:
jakkrits 2023-07-14 11:08:32 +07:00
parent d4e824c50f
commit a4d5e9df6c
2 changed files with 19 additions and 16 deletions

View file

@ -14,11 +14,11 @@ jobs:
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install kubectl # - name: Install kubectl
uses: azure/setup-kubectl@v1 # uses: azure/setup-kubectl@v1
with: # with:
version: 'v1.21.3' # version: 'v1.21.3'
id: install # id: install
- name: Configure AWS credentials - name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1 uses: aws-actions/configure-aws-credentials@v1
@ -31,8 +31,8 @@ jobs:
id: login-ecr id: login-ecr
uses: aws-actions/amazon-ecr-login@v1 uses: aws-actions/amazon-ecr-login@v1
- name: Load secrets and save to app.env # - name: Load secrets and save to app.env
run: aws secretsmanager get-secret-value --secret-id simple_bank --query SecretString --output text | jq -r 'to_entries|map("\(.key)=\(.value)")|.[]' > app.env # run: aws secretsmanager get-secret-value --secret-id simple_bank --query SecretString --output text | jq -r 'to_entries|map("\(.key)=\(.value)")|.[]' > app.env
- name: Build, tag, and push image to Amazon ECR - name: Build, tag, and push image to Amazon ECR
env: env:
@ -43,13 +43,13 @@ jobs:
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
- name: Update kube config # - name: Update kube config
run: aws eks update-kubeconfig --name seleneks --region ap-southeast-1 # run: aws eks update-kubeconfig --name seleneks --region ap-southeast-1
- name: Deploy image to Amazon EKS # - name: Deploy image to Amazon EKS
run: | # run: |
kubectl apply -f eks/aws-auth.yaml # kubectl apply -f eks/aws-auth.yaml
kubectl apply -f eks/deployment.yaml # kubectl apply -f eks/deployment.yaml
kubectl apply -f eks/service.yaml # kubectl apply -f eks/service.yaml
kubectl apply -f eks/issuer.yaml # kubectl apply -f eks/issuer.yaml
kubectl apply -f eks/ingress.yaml # kubectl apply -f eks/ingress.yaml

View file

@ -21,3 +21,6 @@
- AWS_ACCESS_KEY_ID - AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY - AWS_SECRET_ACCESS_KEY
- setup Branch protection rule
- checkout new feature branch, merge request, delete branch