some fix CI
This commit is contained in:
85
.github/workflows/pipeline.yml
vendored
85
.github/workflows/pipeline.yml
vendored
@@ -91,21 +91,21 @@ jobs:
|
|||||||
htmlcov/
|
htmlcov/
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
- name: Send test results notification
|
- name: Send test failure notification
|
||||||
if: always()
|
if: failure()
|
||||||
uses: appleboy/telegram-action@v1.0.0
|
uses: appleboy/telegram-action@v1.0.0
|
||||||
with:
|
with:
|
||||||
to: ${{ secrets.TELEGRAM_CHAT_ID }}
|
to: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||||
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
message: |
|
message: |
|
||||||
${{ job.status == 'success' && '✅' || '❌' }} CI Tests: ${{ job.status }}
|
❌ CI Tests Failed
|
||||||
|
|
||||||
📦 Repository: prod
|
📦 Repository: prod
|
||||||
🌿 Branch: ${{ github.ref_name }}
|
🌿 Branch: ${{ github.ref_name }}
|
||||||
📝 Commit: ${{ github.sha }}
|
📝 Commit: ${{ github.sha }}
|
||||||
👤 Author: ${{ github.actor }}
|
👤 Author: ${{ github.actor }}
|
||||||
|
|
||||||
${{ job.status == 'success' && '✅ All tests passed! Pull request will be created.' || '❌ Tests failed! Deployment blocked.' }}
|
❌ Tests failed! Deployment blocked. Please fix the issues and try again.
|
||||||
|
|
||||||
🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -174,38 +174,57 @@ jobs:
|
|||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: steps.check-pr.outputs.exists == 'false'
|
if: steps.check-pr.outputs.exists == 'false'
|
||||||
id: create-pr
|
id: create-pr
|
||||||
uses: peter-evans/create-pull-request@v5
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
script: |
|
||||||
branch: ${{ github.ref_name }}
|
const branchName = context.ref.replace('refs/heads/', '');
|
||||||
base: main
|
|
||||||
title: "Merge ${{ github.ref_name }} into main"
|
console.log(`📝 Creating PR from ${branchName} to main...`);
|
||||||
body: |
|
|
||||||
## Changes
|
try {
|
||||||
|
const { data: pr } = await github.rest.pulls.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
title: `Merge ${branchName} into main`,
|
||||||
|
head: branchName,
|
||||||
|
base: 'main',
|
||||||
|
body: `## Changes
|
||||||
|
|
||||||
This PR was automatically created after successful CI tests.
|
This PR was automatically created after successful CI tests.
|
||||||
|
|
||||||
- Branch: `${{ github.ref_name }}`
|
- Branch: \`${branchName}\`
|
||||||
- Commit: `${{ github.sha }}`
|
- Commit: \`${{ github.sha }}\`
|
||||||
- Author: @${{ github.actor }}
|
- Author: @${{ github.actor }}
|
||||||
|
|
||||||
## Test Results
|
## Test Results
|
||||||
|
|
||||||
✅ All tests passed successfully!
|
✅ All tests passed successfully!
|
||||||
|
|
||||||
Please review the changes and merge when ready.
|
Please review the changes and merge when ready.`,
|
||||||
labels: |
|
|
||||||
automated
|
|
||||||
ready-for-review
|
|
||||||
draft: false
|
draft: false
|
||||||
|
});
|
||||||
|
|
||||||
- name: Get created PR number
|
// Добавляем labels
|
||||||
if: steps.check-pr.outputs.exists == 'false' && steps.create-pr.outcome == 'success'
|
try {
|
||||||
id: get-pr-number
|
await github.rest.issues.addLabels({
|
||||||
uses: actions/github-script@v6
|
owner: context.repo.owner,
|
||||||
with:
|
repo: context.repo.repo,
|
||||||
script: |
|
issue_number: pr.number,
|
||||||
const branchName = context.ref.replace('refs/heads/', '');
|
labels: ['automated', 'ready-for-review']
|
||||||
|
});
|
||||||
|
} catch (labelError) {
|
||||||
|
console.log(`⚠️ Could not add labels: ${labelError.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
core.setOutput('number', pr.number.toString());
|
||||||
|
core.setOutput('url', pr.html_url);
|
||||||
|
console.log(`✅ PR #${pr.number} created successfully: ${pr.html_url}`);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Failed to create PR: ${error.message}`);
|
||||||
|
if (error.status === 422) {
|
||||||
|
console.log('⚠️ PR might already exist or branch is up to date with base');
|
||||||
|
// Пробуем найти существующий PR
|
||||||
const { data: prs } = await github.rest.pulls.list({
|
const { data: prs } = await github.rest.pulls.list({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
@@ -215,8 +234,18 @@ jobs:
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (prs.length > 0) {
|
if (prs.length > 0) {
|
||||||
core.setOutput('number', prs[0].number);
|
const pr = prs[0];
|
||||||
core.setOutput('url', prs[0].html_url);
|
core.setOutput('number', pr.number.toString());
|
||||||
|
core.setOutput('url', pr.html_url);
|
||||||
|
console.log(`✅ Found existing PR #${pr.number}: ${pr.html_url}`);
|
||||||
|
} else {
|
||||||
|
core.setOutput('number', '');
|
||||||
|
core.setOutput('url', `${{ github.server_url }}/${{ github.repository }}/pulls`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Send PR notification - PR exists
|
- name: Send PR notification - PR exists
|
||||||
@@ -252,9 +281,9 @@ jobs:
|
|||||||
📝 Commit: ${{ github.sha }}
|
📝 Commit: ${{ github.sha }}
|
||||||
👤 Author: ${{ github.actor }}
|
👤 Author: ${{ github.actor }}
|
||||||
|
|
||||||
✅ All tests passed! Pull request #${{ steps.get-pr-number.outputs.number }} has been created and is ready for review.
|
${{ steps.create-pr.outputs.number != '' && format('✅ All tests passed! Pull request #{0} has been created and is ready for review.', steps.create-pr.outputs.number) || '✅ All tests passed! Pull request has been created and is ready for review.' }}
|
||||||
|
|
||||||
🔗 View PR: ${{ steps.get-pr-number.outputs.url }}
|
${{ steps.create-pr.outputs.url != '' && format('🔗 View PR: {0}', steps.create-pr.outputs.url) || format('🔗 View PRs: {0}/{1}/pulls', github.server_url, github.repository) }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
rollback:
|
rollback:
|
||||||
|
|||||||
Reference in New Issue
Block a user