From 930bade776c91c89ed0f234ad35b893f59cb7fb5 Mon Sep 17 00:00:00 2001 From: waelabdallah Date: Mon, 11 Nov 2024 14:13:48 +0100 Subject: [PATCH] version0 pipeline catalog --- .github/workflows/catalog-service-ci-cd.yml | 64 +++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/catalog-service-ci-cd.yml diff --git a/.github/workflows/catalog-service-ci-cd.yml b/.github/workflows/catalog-service-ci-cd.yml new file mode 100644 index 00000000..3a5eff03 --- /dev/null +++ b/.github/workflows/catalog-service-ci-cd.yml @@ -0,0 +1,64 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - service-catalog + pull_request: + branches: + - service-catalog + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + + - name: Build with Quarkus + run: | + cd catalog/catalog-service/ + quarkus build + + - name: Run Tests + run: | + cd catalog/catalog-service/ + quarkus test + + - name: Set Docker Image Tag + id: docker_tag + run: echo "tag=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: Build Docker image + run: | + cd catalog/catalog-service/ + docker-compose up --build -d + + - name: Push Docker image + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + docker push /:${{ env.tag }} + + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to VM + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.VM_HOST }} + username: ${{ secrets.VM_USERNAME }} + key: ${{ secrets.VM_SSH_KEY }} + script: | + docker pull /:${{ needs.build.outputs.tag }} + docker-compose down + docker-compose up -d