image fix #22
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: 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 }} | |
registry: art.montkim.com | |
- 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 "art.montkim.com/study/my-gitbook:${{ env.SHORT_SHA }}" . | |
docker push "art.montkim.com/study/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: art.montkim.com/study/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 | |