Update build_and_deploy.yaml #4
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 | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
IMAGE_TAG: ${{ github.run_number }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
env: | |
IMAGE_TAG: ${{ github.run_number }} | |
with: | |
context: . | |
push: true | |
tags: minjuncho/blms-fe:${{ env.IMAGE_TAG }} | |
id: docker_build | |
- name: Output the image tag | |
run: echo "IMAGE_TAG=${{ steps.docker_build.outputs.digest }}" >> $GITHUB_ENV | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out infra-ops repository | |
uses: actions/checkout@v2 | |
with: | |
repository: "keiburu-Tai/infra-ops" | |
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
fetch-depth: 0 | |
- name: List directory contents | |
run: ls -R | |
- name: Update Kubernetes Manifests | |
env: | |
IMAGE_TAG: ${{ github.run_number }} | |
run: | | |
sed -i 's|image:.*fe.*|image: blms-fe:${{ env.IMAGE_TAG }}|' service/blms/values.yaml | |
- name: commit and push | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git commit -am "Deploying image ${{ env.IMAGE_TAG }}" | |
git push origin main |