From 48586b2ed777c64776245f1911f48d82636ced6c Mon Sep 17 00:00:00 2001 From: Dean Lofts Date: Fri, 25 Oct 2024 15:59:55 +1100 Subject: [PATCH] test cicd --- .github/workflows/01.deploy.yml | 15 ++++++++--- .github/workflows/rollback.yml | 47 --------------------------------- 2 files changed, 12 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/rollback.yml diff --git a/.github/workflows/01.deploy.yml b/.github/workflows/01.deploy.yml index b6d2bc7..e57f211 100644 --- a/.github/workflows/01.deploy.yml +++ b/.github/workflows/01.deploy.yml @@ -9,15 +9,24 @@ on: workflow_dispatch: push: branches: - - dl/kamal-2-test + - dl/kamal-2-test # Change to 'main' branch + + # Trigger deployment only after the CI workflow completes successfully + workflow_run: + workflows: ["CI"] # Ensure this matches the name of your CI workflow + types: + - completed jobs: deploy: name: Deploy runs-on: ubuntu-latest - environment: staging + environment: production # Adjust to 'production' timeout-minutes: 20 + # Only run if CI was successful + if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' + steps: - uses: actions/checkout@v4 @@ -55,4 +64,4 @@ jobs: RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} DOCKER_BUILDKIT: 1 run: | - ./bin/kamal deploy \ No newline at end of file + ./bin/kamal deploy diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml deleted file mode 100644 index 8c29bd4..0000000 --- a/.github/workflows/rollback.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Rollback - -on: - workflow_dispatch: - inputs: - tag: - description: 'Release tag to rollback' - required: true - -jobs: - rollback: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GH_PAT }} - - - name: Deploy rollback to droplet - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.DROPLET_IP }} - username: root - key: ${{ secrets.DROPLET_SSH_PRIVATE_KEY }} - script: | - echo "${{ secrets.GH_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - # Stop the running containers - docker compose -f docker-compose.prod.yml down - - # Pull the specific release tag - docker compose -f docker-compose.prod.yml pull ghcr.io/loftwah/linkarooie:${{ github.event.inputs.tag }} - - # Start the rolled-back version of the containers - docker compose -f docker-compose.prod.yml up -d - - # Remove unused images and containers - docker system prune -af