Skip to content

Merge pull request #41 from H-Seon43/main #29

Merge pull request #41 from H-Seon43/main

Merge pull request #41 from H-Seon43/main #29

name: Build and Push Docker Image and Modify EKS Repo
on:
push:
branches:
- main
jobs:
build-and-push-docker:
if: github.repository == 'devPracticeCenter/hands-on-expert'
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ secrets.DOCKER_USERNAME }}/cicd-practice:${{ github.sha }}
steps:
- uses: actions/checkout@v2
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.IMAGE_TAG }}
modify-eks-repo:
needs: build-and-push-docker
if: github.repository == 'devPracticeCenter/hands-on-expert'
runs-on: ubuntu-latest
env:
EKS_PATH: helm-projects/handson-expert
IMAGE_TAG: ${{ secrets.DOCKER_USERNAME }}/cicd-practice:${{ github.sha }}
steps:
- uses: actions/checkout@v2
with:
repository: devPracticeCenter/eks-apps
token: ${{ secrets.REPO_TOKEN }}
path: eks-apps
- name: Modify Files and Commit
run: |
cd eks-apps
mkdir -p ${{ env.EKS_PATH}}
echo '"replicaCount": "1"' > ${{ env.EKS_PATH }}/values.yaml
echo '"image": "${{ env.IMAGE_TAG }}"' >> ${{ env.EKS_PATH }}/values.yaml
echo '"host": "handson-expert.geunsam2.xyz"' >> ${{ env.EKS_PATH }}/values.yaml
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Update file.txt by GitHub Actions[handson-expert]"
- name: Push Changes
run: |
cd eks-apps
git pull --rebase
git push