Merge dev-4 into main #4

Merged
KerradKerridi merged 5 commits from dev-4 into main 2026-01-25 16:58:22 +00:00
Showing only changes of commit 5e57e5214c - Show all commits

View File

@@ -91,21 +91,21 @@ jobs:
htmlcov/
retention-days: 7
- name: Send test results notification
if: always()
- name: Send test failure notification
if: failure()
uses: appleboy/telegram-action@v1.0.0
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: |
${{ job.status == 'success' && '✅' || '❌' }} CI Tests: ${{ job.status }}
❌ CI Tests Failed
📦 Repository: prod
🌿 Branch: ${{ github.ref_name }}
📝 Commit: ${{ github.sha }}
👤 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 }}
continue-on-error: true
@@ -174,38 +174,57 @@ jobs:
- name: Create Pull Request
if: steps.check-pr.outputs.exists == 'false'
id: create-pr
uses: peter-evans/create-pull-request@v5
uses: actions/github-script@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
base: main
title: "Merge ${{ github.ref_name }} into main"
body: |
## Changes
script: |
const branchName = context.ref.replace('refs/heads/', '');
console.log(`📝 Creating PR from ${branchName} to main...`);
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.
- Branch: `${{ github.ref_name }}`
- Commit: `${{ github.sha }}`
- Branch: \`${branchName}\`
- Commit: \`${{ github.sha }}\`
- Author: @${{ github.actor }}
## Test Results
✅ All tests passed successfully!
Please review the changes and merge when ready.
labels: |
automated
ready-for-review
Please review the changes and merge when ready.`,
draft: false
});
- name: Get created PR number
if: steps.check-pr.outputs.exists == 'false' && steps.create-pr.outcome == 'success'
id: get-pr-number
uses: actions/github-script@v6
with:
script: |
const branchName = context.ref.replace('refs/heads/', '');
// Добавляем labels
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
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({
owner: context.repo.owner,
repo: context.repo.repo,
@@ -215,8 +234,18 @@ jobs:
});
if (prs.length > 0) {
core.setOutput('number', prs[0].number);
core.setOutput('url', prs[0].html_url);
const pr = prs[0];
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
@@ -252,9 +281,9 @@ jobs:
📝 Commit: ${{ github.sha }}
👤 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
rollback: