diff --git a/.github/workflows/cd.dev.yml.bac b/.github/workflows/cd.dev.yaml similarity index 60% rename from .github/workflows/cd.dev.yml.bac rename to .github/workflows/cd.dev.yaml index fcb167d96..2ebf6cc75 100644 --- a/.github/workflows/cd.dev.yml.bac +++ b/.github/workflows/cd.dev.yaml @@ -1,16 +1,16 @@ name: Dev Branch Deployment on: - workflow_run: - workflows: ["CI"] - types: - - completed + push: branches: [dev] + paths-ignore: + - "README.md" + - ".github/workflows/**" + workflow_dispatch: jobs: - on-success: + deploy: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -22,14 +22,9 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} script: | - cd python/dev_source_code/ + cd boilerplate-python/dev/ git pull origin dev source .venv/bin/activate pip install -r requirements.txt alembic upgrade head - on-failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: echo 'The triggering workflow failed' diff --git a/.github/workflows/cd.dev.yml b/.github/workflows/cd.dev.yml deleted file mode 100644 index dc018e8f5..000000000 --- a/.github/workflows/cd.dev.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Dev cd pipeline -on: - push: - branches: [dev] - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Build image - run: docker build -t anchor-python-bp-dev:latest -f Dockerfile . - - - name: Save image - run: docker save anchor-python-bp-dev:latest | gzip > dev.tar.gz - - - name: Copy image to server - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - source: "dev.tar.gz" - target: "/home/${{ secrets.USERNAME }}/boilerplate-python/dev_source_code" - - - name: Deploy image on server - uses: appleboy/ssh-action@v0.1.8 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - cd /home/${{ secrets.USERNAME }}/boilerplate-python/dev_source_code - git pull origin dev - docker load --input dev.tar.gz - docker compose -f docker-compose.yml up -d - rm -f dev.tar.gz - diff --git a/.github/workflows/cd.prod.yml.bac b/.github/workflows/cd.prod.yaml similarity index 61% rename from .github/workflows/cd.prod.yml.bac rename to .github/workflows/cd.prod.yaml index 23217d2e5..f65f90954 100644 --- a/.github/workflows/cd.prod.yml.bac +++ b/.github/workflows/cd.prod.yaml @@ -1,16 +1,16 @@ name: Prod Branch Deployment on: - workflow_run: - workflows: ["CI"] - types: - - completed + push: branches: [main] + paths-ignore: + - "README.md" + - ".github/workflows/**" + workflow_dispatch: jobs: on-success: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -22,14 +22,9 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} script: | - cd python/prod_source_code/ + cd boilerplate-python/prod/ git pull origin main source .venv/bin/activate pip install -r requirements.txt alembic upgrade head - on-failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: echo 'The triggering workflow failed' diff --git a/.github/workflows/cd.prod.yml b/.github/workflows/cd.prod.yml deleted file mode 100644 index 46dff1e8f..000000000 --- a/.github/workflows/cd.prod.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Prod cd pipeline -on: - push: - branches: [main] - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Build image - run: docker build -t anchor-python-bp-prod:latest -f Dockerfile . - - - name: Save image - run: docker save anchor-python-bp-prod:latest | gzip > prod.tar.gz - - - name: Copy image to server - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - source: "prod.tar.gz" - target: "/home/${{ secrets.USERNAME }}/boilerplate-python/prod_source_code" - - - name: Deploy image on server - uses: appleboy/ssh-action@v0.1.8 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - cd /home/${{ secrets.USERNAME }}/boilerplate-python/prod_source_code - git pull origin main - docker load --input prod.tar.gz - docker compose -f docker-compose.prod.yml up -d - rm -f prod.tar.gz diff --git a/.github/workflows/cd.staging.yml.bac b/.github/workflows/cd.staging.yaml similarity index 69% rename from .github/workflows/cd.staging.yml.bac rename to .github/workflows/cd.staging.yaml index 7de13a1b6..5138accb7 100644 --- a/.github/workflows/cd.staging.yml.bac +++ b/.github/workflows/cd.staging.yaml @@ -1,11 +1,12 @@ name: Staging Branch Deployment on: - workflow_run: - workflows: ["CI"] - types: - - completed + push: branches: [staging] + paths-ignore: + - "README.md" + - ".github/workflows/**" + workflow_dispatch: jobs: on-success: @@ -22,14 +23,8 @@ jobs: username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} script: | - cd python/staging_source_code/ + cd boilerplate-python/staging/ git pull origin staging source .venv/bin/activate pip install -r requirements.txt alembic upgrade head - - on-failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: echo 'The triggering workflow failed' diff --git a/.github/workflows/cd.staging.yml b/.github/workflows/cd.staging.yml deleted file mode 100644 index cdc182adc..000000000 --- a/.github/workflows/cd.staging.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Staging cd pipeline -on: - push: - branches: [staging] - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Build image - run: docker build -t anchor-python-bp-staging:latest -f Dockerfile . - - - name: Save image - run: docker save anchor-python-bp-staging:latest | gzip > staging.tar.gz - - - name: Copy image to server - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - source: "staging.tar.gz" - target: "/home/${{ secrets.USERNAME }}/boilerplate-python/staging_source_code" - - - name: Deploy image on server - uses: appleboy/ssh-action@v0.1.8 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - cd /home/${{ secrets.USERNAME }}/boilerplate-python/staging_source_code - git pull origin staging - docker load --input staging.tar.gz - docker compose -f docker-compose.staging.yml up -d - rm -f staging.tar.gz diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1500c277a..3b86b3f40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,8 @@ name: CI on: - push: - branches: [main, staging, dev, devops-main] - paths-ignore: - - "README.md" - - ".github/workflows/**" pull_request: - branches: [main, staging, dev, devops-main] + types: [opened, synchronize, reopened] paths-ignore: - "README.md" - ".github/workflows/**" @@ -28,7 +23,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml.bkp similarity index 100% rename from .github/workflows/pr-deploy.yml rename to .github/workflows/pr-deploy.yml.bkp diff --git a/.github/workflows/test.yml.bac b/.github/workflows/test.yml.bac deleted file mode 100644 index 621a3a634..000000000 --- a/.github/workflows/test.yml.bac +++ /dev/null @@ -1,53 +0,0 @@ -name: Test -on: - pull_request: - types: [opened, synchronize, reopened, closed] - paths-ignore: - - "README.md" - - ".github/workflows/**" - -jobs: - test: - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:latest - env: - POSTGRES_USER: "username" - POSTGRES_PASSWORD: "password" - POSTGRES_DB: "test" - ports: - - 5432:5432 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.12" - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install dependencies - run: | - pip install -r requirements.txt - - - name: Copy env file - run: cp .env.sample .env - - - name: Run migrations - run: | - alembic upgrade head - - - name: Run tests - run: | - PYTHONPATH=. pytest