Merge pull request #5 from mildKim/main #17
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: Build and Push Docker Image and Modify EKS Repo | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push-docker: | |
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 | |
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 |