From 0944175807f44c51ab613fc9075fed7a3141297c Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 25 Jan 2026 15:39:19 +0300 Subject: [PATCH] chore: enhance CI and deployment workflows with status checks and notifications - Updated CI workflow to provide clearer notifications on test results and deployment readiness. - Added a new job in the deployment workflow to check the status of the last CI run before proceeding with deployment, ensuring that only successful builds are deployed. --- .github/workflows/ci.yml | 4 +++- .github/workflows/deploy.yml | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fa7afb..4fcae85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,9 @@ jobs: Commit: ${{ github.sha }} Author: ${{ github.actor }} - ${{ job.status == 'success' && '✅ All tests passed!' || '❌ Tests failed!' }} + ${{ job.status == 'success' && '✅ All tests passed! Ready for deployment.' || '❌ Tests failed! Deployment blocked.' }} + + ${{ job.status == 'success' && format('🚀 You can now deploy manually: {0}/{1}/actions/workflows/deploy.yml', github.server_url, github.repository) || '' }} View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b11341e..acc1b23 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,9 +4,53 @@ on: workflow_dispatch: # Только ручной запуск jobs: + check-ci-status: + runs-on: ubuntu-latest + name: Check CI Status + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check last CI run status + uses: actions/github-script@v7 + with: + script: | + const { data: runs } = await github.rest.actions.listWorkflowRuns({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'ci.yml', + branch: 'main', + per_page: 1 + }); + + if (runs.workflow_runs.length === 0) { + core.setFailed('❌ No CI runs found. Please run CI first.'); + return; + } + + const lastRun = runs.workflow_runs[0]; + const status = lastRun.status; + const conclusion = lastRun.conclusion; + + console.log(`Last CI run: ${lastRun.id}`); + console.log(`Status: ${status}, Conclusion: ${conclusion}`); + + if (status !== 'completed') { + core.setFailed(`❌ Last CI run is still ${status}. Please wait for it to complete.`); + return; + } + + if (conclusion !== 'success') { + core.setFailed(`❌ Last CI run failed (${conclusion}). Please fix tests before deploying.`); + return; + } + + console.log('✅ Last CI run passed successfully. Ready for deployment!'); + deploy: runs-on: ubuntu-latest name: Deploy Infrastructure + needs: check-ci-status steps: - name: Checkout code