Skip to content

Commit

Permalink
add cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
idoyo7 committed Nov 30, 2024
1 parent 1e4af22 commit 569fac4
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/dokcer-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docker Image CI/CD

on:
push:
branches:
- main

permissions:
contents: write

jobs:
build-and-push:
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout 'study' repository
uses: actions/checkout@v3

- name: Login to Docker Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract short SHA
id: vars
run: echo "SHORT_SHA=${GITHUB_SHA::6}" >> $GITHUB_ENV

- name: Build and push Docker image
run: |
docker build -t "${{ secrets.DOCKER_USERNAME }}/my-gitbook:${{ env.SHORT_SHA }}" .
docker push "${{ secrets.DOCKER_USERNAME }}/my-gitbook:${{ env.SHORT_SHA }}"
- name: Checkout 'study-manifests' repository
uses: actions/checkout@v3
with:
repository: idoyo7/study-manifests
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
path: study-manifests

- name: Update manifest files
run: |
cd study-manifests
# 필요한 수정 작업 수행 (예: 이미지 태그 업데이트)
sed -i 's|image:.*|image: '"${{ secrets.DOCKER_USERNAME }}/my-gitbook:${{ env.SHORT_SHA }}"'|' deployment.yaml
- name: Commit and push changes to 'study-manifests'
run: |
cd study-manifests
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add .
git commit -m "Update image tag to ${{ env.SHORT_SHA }}"
git push

0 comments on commit 569fac4

Please sign in to comment.