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.
This commit is contained in:
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -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
|
||||
|
||||
44
.github/workflows/deploy.yml
vendored
44
.github/workflows/deploy.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user