From abc74aaa64752ee4735f8a183e525e3ae9c842a9 Mon Sep 17 00:00:00 2001 From: Gil Maimon Date: Sat, 27 Jul 2024 00:11:09 +0300 Subject: [PATCH] Create cicd.yaml --- .github/workflows/cicd.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/cicd.yaml diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..f7ed30f --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,35 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - '**' # Triggers on push to any branch + - '!master' # Exclude master branch + pull_request: + branches: + - master # Triggers on PR to master branch + workflow_dispatch: # Manually trigger the workflow + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build Docker image + run: docker build -t server . + + - name: Push Docker image + if: github.ref == 'refs/heads/master' + run: docker push server:latest