diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 26bfba1d..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Realse Version - -on: - push: - branches: - - master - paths: - - 'app/**' - - 'web/**' - - 'crawl/**' - -jobs: - releaseGithub: - runs-on: ubuntu-22.04 - permissions: - contents: write - pull-requests: write - steps: - - name: Bump version and push tag - id: bump - uses: mathieudutour/github-tag-action@v6.2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - default_bump: patch - - - name: Build Changelog - id: github_release - uses: mikepenz/release-changelog-builder-action@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - fromTag: ${{ steps.bump.outputs.previous_tag }} - toTag: ${{ steps.bump.outputs.new_tag }} - - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - body: ${{ steps.bump.outputs.changelog }} - tag_name: ${{ steps.bump.outputs.new_tag }} - - releaseDocker: - runs-on: ubuntu-latest - needs: releaseGithub - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: install requirements - run: pip install -r requirements.txt - - - name: docker login - uses: docker/login-action@v3 - with: - username: 81318131 - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: build services - run: docker compose build - - - name: push images - run: docker compose push diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 00000000..7f8ec22a --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,88 @@ +name: Realse Version + +on: + push: + branches: + - master + - dev + paths: + - 'app/**' + - 'crawl/**' + +jobs: + releaseGithub: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-22.04 + permissions: + contents: write + pull-requests: write + steps: + - name: Bump version and push tag + id: bump + uses: mathieudutour/github-tag-action@v6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + default_bump: patch + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + fromTag: ${{ steps.bump.outputs.previous_tag }} + toTag: ${{ steps.bump.outputs.new_tag }} + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + body: ${{ steps.bump.outputs.changelog }} + tag_name: ${{ steps.bump.outputs.new_tag }} + + releaseDockerWithDeployment: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKER_USERNAME }}/devopsgpt-fastapi:${{ github.ref_name }} + + - name: Deploying landing prod on the remote server + if: github.ref == 'refs/heads/master' + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.HOST_USERNAME }} + password: ${{ secrets.HOST_PASSWORD }} + port: ${{ secrets.HOST_PORT }} + script: docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml down fastapi_prod && docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml up -d --pull always fastapi_prod + + - name: Deploying landing dev on the remote server + if: github.ref == 'refs/heads/dev' + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.HOST_USERNAME }} + password: ${{ secrets.HOST_PASSWORD }} + port: ${{ secrets.HOST_PORT }} + script: docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml down fastapi_dev && docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml up -d --pull always fastapi_dev + + - name: Removing dangle images on the remote server + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.HOST_USERNAME }} + password: ${{ secrets.HOST_PASSWORD }} + port: ${{ secrets.HOST_PORT }} + script: docker image prune -f diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 529e1fdb..7869a585 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,11 +20,6 @@ jobs: - name: install requirements run: pip install -r requirements.txt - - name: docker login - uses: docker/login-action@v3 - with: - username: 81318131 - password: ${{ secrets.DOCKER_PASSWORD }} - name: build services run: docker compose build diff --git a/Makefile b/Makefile index 5b552a6f..156d0b92 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ namespace ?= default releaseName ?= devopsgpt -all: build up +all: update-submodule build up + +update-submodule: + git submodule init && git submodule update build: docker compose build diff --git a/app/tests/conftest.py b/app/tests/conftest.py index bd6af348..55bc327a 100644 --- a/app/tests/conftest.py +++ b/app/tests/conftest.py @@ -19,6 +19,7 @@ def client(): return TestClient(app) + @pytest.fixture def iac_template_docker_sample_input(): return IaCTemplateGenerationDocker().model_dump() diff --git a/docker-compose.yml b/docker-compose.yml index 38c9e32b..568ba729 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: context: . dockerfile: Dockerfile - image: 81318131/fastapi_gpt + image: fastapi_gpt container_name: fastapi_gpt command: fastapi run app/main.py --port 8080 volumes: @@ -24,7 +24,7 @@ services: dockerfile: Dockerfile args: VITE_API_CLIENT_BASE_URL: "http://localhost:8080/api/" - image: 81318131/web_gpt + image: web_gpt container_name: web_gpt ports: - "80:4173"