From fd2cde1f31c13d32971b0a3a8e7a7c55d56262d1 Mon Sep 17 00:00:00 2001 From: AbdulrhmanGoni Date: Fri, 1 Nov 2024 00:21:43 +0300 Subject: [PATCH 1/2] ci: rename `tests.yaml` workflow file to `ci.yaml` --- .github/workflows/{tests.yaml => ci.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{tests.yaml => ci.yaml} (90%) diff --git a/.github/workflows/tests.yaml b/.github/workflows/ci.yaml similarity index 90% rename from .github/workflows/tests.yaml rename to .github/workflows/ci.yaml index ff1fa80..0ceae06 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,11 @@ -name: Tests Workflow +name: Continous Integration Workflow on: push: workflow_dispatch: jobs: - setup-and-run-tests: + run-tests-and-collect-coverage: runs-on: ubuntu-latest steps: - name: Checkout From b370595f50267e9b25cf45495ed80545ec605c15 Mon Sep 17 00:00:00 2001 From: AbdulrhmanGoni Date: Fri, 1 Nov 2024 00:24:37 +0300 Subject: [PATCH 2/2] ci: add `build-and-deploy` job to `ci.yaml` workflow file Add `build-and-deploy` job to `ci.yaml` workflow file runs only on main branch to build a docker image for the server app and deploy it to docker hub. Make the step of collecting tests code coverage and deploying it to Codecov runs only on main branch. --- .github/workflows/ci.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0ceae06..065cc21 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,25 @@ jobs: run: bun test --coverage --coverage-reporter=lcov - name: Upload code coverage to Codecov + if: github.ref_name == 'main' uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage/lcov.info + + build-and-deploy: + if: github.ref_name == 'main' + needs: run-tests-and-collect-coverage + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Docker Image + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/llms-tdm-server . + + - name: Log in to Docker hub + run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + + - name: Push the Docker Image to Docker hub + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/llms-tdm-server