Update greetings.yml #1
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 Deploy | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- backend | |
jobs: | |
build: | |
name: "building docker image" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set outputs | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Check outputs | |
run: echo ${{ steps.vars.outputs.sha_short }} | |
- name: find and replace docker image version | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "latest" | |
replace: "${{ steps.vars.outputs.sha_short }}" | |
include: "service.yml" | |
regex: true | |
- name: "build image" | |
run: | | |
docker build -t pranshugupta54/backend:${{ steps.vars.outputs.sha_short }} -f backend.Dockerfile . | |
- name: push | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo "${{ secrets.DOCKER_HUB_PASS }}" | docker login -u "pranshugupta54" --password-stdin | |
docker push pranshugupta54/backend:${{ steps.vars.outputs.sha_short }} | |
- name: replace service file for meltcd | |
if: github.ref == 'refs/heads/main' | |
uses: dmnemec/copy_file_to_another_repo_action@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.GH_PERM }} | |
BUILD_VERSION: ${{ steps.vars.outputs.sha_short }} | |
with: | |
source_file: 'service.yml' | |
destination_repo: 'digitomize/infra' | |
destination_branch: 'main' | |
user_email: '[email protected]' | |
user_name: 'pranshugupta54' | |
commit_message: 'Update docker image version for MeltCD' |