Skip to content

Commit

Permalink
Create build_deploy.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 authored Mar 13, 2024
1 parent 26db3b9 commit ee18b80
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build

on:
push:
branches: ["main"]

jobs:
build-dev:
name: Build and push dev Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Tag in env variable
run: |
echo "sha_short=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "${{ secrets.DOCKER_USER }}/${{ secrets.REPOSITORY_NAME }}" > APP_NAME
echo "$GITHUB_SHA" > TAG
- name: Build the Docker image
run: docker build . --file Dockerfile --tag $(cat APP_NAME):dev-${{ github.sha }}
- name: Tag the image to commit
run: docker tag $(cat APP_NAME):dev-${{ github.sha }} $(cat APP_NAME):dev-${{ github.sha }}
- name: Docker Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
- name: Image push
run: docker push $(cat APP_NAME):dev-${{ github.sha }}
build:
name: Build and push Docker image
runs-on: ubuntu-latest
needs: build-dev
steps:
- uses: actions/checkout@v4
- name: Set Tag in env variable
run: |
echo "sha_short=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "${{ secrets.DOCKER_USER }}/${{ secrets.REPOSITORY_NAME }}" > APP_NAME
echo "$GITHUB_SHA" > TAG
- name: Build the Docker image
run: docker build . --file Dockerfile --tag $(cat APP_NAME):${{ github.sha }}
- name: Tag the image to commit
run: docker tag $(cat APP_NAME):${{ github.sha }} $(cat APP_NAME):${{ github.sha }}
- name: Docker Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
- name: Image push
run: docker push $(cat APP_NAME):${{ github.sha }}

0 comments on commit ee18b80

Please sign in to comment.