From ee18b80f5a34d7ef3b8819d8ee302cb14fec71ff Mon Sep 17 00:00:00 2001 From: Raaj Patel <41763998+Raajheer1@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:58:12 -0500 Subject: [PATCH] Create build_deploy.yaml --- .github/workflows/build_deploy.yaml | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/build_deploy.yaml diff --git a/.github/workflows/build_deploy.yaml b/.github/workflows/build_deploy.yaml new file mode 100644 index 0000000..81b5f71 --- /dev/null +++ b/.github/workflows/build_deploy.yaml @@ -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 }}