some fix 2
This commit is contained in:
62
.github/workflows/pipeline.yml
vendored
62
.github/workflows/pipeline.yml
vendored
@@ -161,15 +161,27 @@ jobs:
|
|||||||
const prNumber = parseInt('${{ steps.check-pr.outputs.number }}');
|
const prNumber = parseInt('${{ steps.check-pr.outputs.number }}');
|
||||||
const branchName = context.ref.replace('refs/heads/', '');
|
const branchName = context.ref.replace('refs/heads/', '');
|
||||||
|
|
||||||
|
const commitSha = '${{ github.sha }}';
|
||||||
|
const author = '${{ github.actor }}';
|
||||||
|
|
||||||
|
const updateBody = '## Updated Changes\n\n' +
|
||||||
|
'PR updated with new commits after successful CI tests.\n\n' +
|
||||||
|
'- Latest commit: ' + commitSha + '\n' +
|
||||||
|
'- Branch: `' + branchName + '`\n' +
|
||||||
|
'- Author: @' + author + '\n\n' +
|
||||||
|
'## Test Results\n\n' +
|
||||||
|
'✅ All tests passed successfully!\n\n' +
|
||||||
|
'Please review the changes and merge when ready.';
|
||||||
|
|
||||||
await github.rest.pulls.update({
|
await github.rest.pulls.update({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
pull_number: prNumber,
|
pull_number: prNumber,
|
||||||
title: `Merge ${branchName} into main`,
|
title: 'Merge ' + branchName + ' into main',
|
||||||
body: `## Updated Changes\n\nPR updated with new commits after successful CI tests.\n\n- Latest commit: ${{ github.sha }}\n- Branch: \`${branchName}\`\n- Author: @${{ github.actor }}\n\n## Test Results\n\n✅ All tests passed successfully!\n\nPlease review the changes and merge when ready.`
|
body: updateBody
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`✅ PR #${prNumber} updated successfully`);
|
console.log('✅ PR #' + prNumber + ' updated successfully');
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: steps.check-pr.outputs.exists == 'false'
|
if: steps.check-pr.outputs.exists == 'false'
|
||||||
@@ -179,28 +191,28 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
const branchName = context.ref.replace('refs/heads/', '');
|
const branchName = context.ref.replace('refs/heads/', '');
|
||||||
|
|
||||||
console.log(`📝 Creating PR from ${branchName} to main...`);
|
console.log('📝 Creating PR from ' + branchName + ' to main...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const commitSha = '${{ github.sha }}';
|
||||||
|
const author = '${{ github.actor }}';
|
||||||
|
|
||||||
|
const prBody = '## Changes\n\n' +
|
||||||
|
'This PR was automatically created after successful CI tests.\n\n' +
|
||||||
|
'- Branch: `' + branchName + '`\n' +
|
||||||
|
'- Commit: `' + commitSha + '`\n' +
|
||||||
|
'- Author: @' + author + '\n\n' +
|
||||||
|
'## Test Results\n\n' +
|
||||||
|
'✅ All tests passed successfully!\n\n' +
|
||||||
|
'Please review the changes and merge when ready.';
|
||||||
|
|
||||||
const { data: pr } = await github.rest.pulls.create({
|
const { data: pr } = await github.rest.pulls.create({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
title: `Merge ${branchName} into main`,
|
title: 'Merge ' + branchName + ' into main',
|
||||||
head: branchName,
|
head: branchName,
|
||||||
base: 'main',
|
base: 'main',
|
||||||
body: `## Changes
|
body: prBody,
|
||||||
|
|
||||||
This PR was automatically created after successful CI tests.
|
|
||||||
|
|
||||||
- Branch: \`${branchName}\`
|
|
||||||
- Commit: \`${{ github.sha }}\`
|
|
||||||
- Author: @${{ github.actor }}
|
|
||||||
|
|
||||||
## Test Results
|
|
||||||
|
|
||||||
✅ All tests passed successfully!
|
|
||||||
|
|
||||||
Please review the changes and merge when ready.`,
|
|
||||||
draft: false
|
draft: false
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -213,22 +225,22 @@ Please review the changes and merge when ready.`,
|
|||||||
labels: ['automated', 'ready-for-review']
|
labels: ['automated', 'ready-for-review']
|
||||||
});
|
});
|
||||||
} catch (labelError) {
|
} catch (labelError) {
|
||||||
console.log(`⚠️ Could not add labels: ${labelError.message}`);
|
console.log('⚠️ Could not add labels: ' + labelError.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.setOutput('number', pr.number.toString());
|
core.setOutput('number', pr.number.toString());
|
||||||
core.setOutput('url', pr.html_url);
|
core.setOutput('url', pr.html_url);
|
||||||
console.log(`✅ PR #${pr.number} created successfully: ${pr.html_url}`);
|
console.log('✅ PR #' + pr.number + ' created successfully: ' + pr.html_url);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`❌ Failed to create PR: ${error.message}`);
|
console.error('❌ Failed to create PR: ' + error.message);
|
||||||
if (error.status === 422) {
|
if (error.status === 422) {
|
||||||
console.log('⚠️ PR might already exist or branch is up to date with base');
|
console.log('⚠️ PR might already exist or branch is up to date with base');
|
||||||
// Пробуем найти существующий PR
|
// Пробуем найти существующий 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,
|
||||||
head: `${context.repo.owner}:${branchName}`,
|
head: context.repo.owner + ':' + branchName,
|
||||||
base: 'main',
|
base: 'main',
|
||||||
state: 'open'
|
state: 'open'
|
||||||
});
|
});
|
||||||
@@ -237,10 +249,12 @@ Please review the changes and merge when ready.`,
|
|||||||
const pr = prs[0];
|
const pr = prs[0];
|
||||||
core.setOutput('number', pr.number.toString());
|
core.setOutput('number', pr.number.toString());
|
||||||
core.setOutput('url', pr.html_url);
|
core.setOutput('url', pr.html_url);
|
||||||
console.log(`✅ Found existing PR #${pr.number}: ${pr.html_url}`);
|
console.log('✅ Found existing PR #' + pr.number + ': ' + pr.html_url);
|
||||||
} else {
|
} else {
|
||||||
core.setOutput('number', '');
|
core.setOutput('number', '');
|
||||||
core.setOutput('url', `${{ github.server_url }}/${{ github.repository }}/pulls`);
|
const serverUrl = '${{ github.server_url }}';
|
||||||
|
const repo = '${{ github.repository }}';
|
||||||
|
core.setOutput('url', serverUrl + '/' + repo + '/pulls');
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user