From a431f3c9e9af689e6a21c1fdf80739d865a2d1c0 Mon Sep 17 00:00:00 2001 From: Stefan <160713072+stefancojocar@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:55:46 +0300 Subject: [PATCH] Create docker-image.yml --- .github/workflows/docker-image.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..6a8b353 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,26 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - develop + - main + +jobs: + build: + name: Build Docker Image + runs-on: ubuntu-latest + environment: ${{ github.ref == 'refs/heads/main' && 'production' || github.ref == 'refs/heads/develop' && 'development' }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.7 + + - name: Set Environment Variables Based on Branch + run: | + echo "DOCKER_IMAGE=${{ vars.ACR }}/web-${{ vars.ENV }}" >> $GITHUB_ENV + + - name: Build and push Docker image + run: | + cp .env.${{ vars.BRANCH_ENV }} .env + docker build -f Dockerfile -t ${{ env.DOCKER_IMAGE }}:latest -t ${{ env.DOCKER_IMAGE }}:$GITHUB_SHA . + echo "${{ env.DOCKER_IMAGE }}:$GITHUB_SHA"