From d037f772a2d9fddc6a20e3740eea1ffd436c262d Mon Sep 17 00:00:00 2001 From: Alejandro Peralta Date: Fri, 22 Nov 2024 14:41:33 +0100 Subject: [PATCH] chore(infrastructure): Enable CI/CD v2 so its ready to be merged with develop --- .github/workflows/cicd v2.yml | 5 ++- .github/workflows/cicd.yml | 57 ----------------------------------- 2 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd v2.yml b/.github/workflows/cicd v2.yml index ed1011e0..aed72637 100644 --- a/.github/workflows/cicd v2.yml +++ b/.github/workflows/cicd v2.yml @@ -30,13 +30,12 @@ jobs: name: Set Deployment Environment needs: [ build-and-test ] runs-on: ubuntu-latest - # if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'develop' || github.ref_name == 'main' }} + if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'develop' || github.ref_name == 'main' }} outputs: env_name: ${{ steps.set_env.outputs.env_name }} steps: - id: set_env - run: echo "env_name=develop" >> $GITHUB_OUTPUT - # run: echo "env_name=${{ github.ref_name == 'main' && 'production' || github.ref_name }}" >> $GITHUB_OUTPUT + run: echo "env_name=${{ github.ref_name == 'main' && 'production' || github.ref_name }}" >> $GITHUB_OUTPUT build_api: name: build-api diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml deleted file mode 100644 index fd3bfd10..00000000 --- a/.github/workflows/cicd.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: CI / CD - -on: - push: - paths: - - "api/**" - - ".github/workflows/cicd.yml" - workflow_dispatch: - -jobs: - build-and-test: - name: Build and Test - runs-on: ubuntu-latest - - steps: - - name: Check out the repository - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and run tests - run: docker compose up --build --exit-code-from test test - - - name: Clean up - run: docker compose down - - deploy: - name: Deploy - runs-on: ubuntu-latest - needs: build-and-test - if: github.ref == 'refs/heads/develop' - steps: - - name: Deploy to EC2 - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.DEV_HOST }} - username: ${{ secrets.USERNAME }} - key: ${{ secrets.SSH_KEY }} - script: | - cd amazonia-360 - git pull --rebase - sudo docker compose down - sudo docker compose up -d api --build - - health-check: - name: Health Check - runs-on: ubuntu-latest - needs: deploy - if: github.ref == 'refs/heads/develop' - steps: - - name: URL Health Check - uses: Jtalk/url-health-check-action@v4 - with: - url: ${{ secrets.DEV_HEALTHCHECK }} - retries: 5 - wait: 10