@@ -36996,9 +36996,6 @@ async function run() {
36996
36996
const autoMerge = core.getBooleanInput('auto_merge') || false;
36997
36997
const addTimestamp = core.getBooleanInput('add_timestamp') || true;
36998
36998
const updateFromSource = core.getBooleanInput('update_from_source') || false;
36999
- if (addTimestamp) {
37000
- branch = `${branch}-${new Date().toISOString().replace(/[:.]/g, '-')}`;
37001
- }
37002
36999
if (!token) {
37003
37000
throw new Error('GitHub token is required. Please provide a token with appropriate permissions.');
37004
37001
}
@@ -37028,7 +37025,9 @@ async function updateFromSourceSpec(token, branch, autoMerge) {
37028
37025
await exec.exec('git', ['config', 'user.name', 'github-actions']);
37029
37026
await exec.exec('git', ['config', 'user.email', 'github-actions@github.com']);
37030
37027
core.info(`Creating and checking out branch: ${branch}`);
37031
- await exec.exec('git', ['checkout', '-b', branch]);
37028
+ const octokit = github.getOctokit(token);
37029
+ const doesBranchExist = await branchExists(owner, repo, branch, octokit);
37030
+ await setupBranch(branch, doesBranchExist);
37032
37031
await runFernApiUpdate();
37033
37032
const diff = await exec.getExecOutput('git', ['status', '--porcelain'], { silent: true });
37034
37033
if (!diff.stdout.trim()) {
@@ -37038,7 +37037,7 @@ async function updateFromSourceSpec(token, branch, autoMerge) {
37038
37037
await exec.exec('git', ['add', '.'], { silent: true });
37039
37038
await exec.exec('git', ['commit', '-m', 'Update API specifications with fern api update'], { silent: true });
37040
37039
core.info(`Pushing changes to branch: ${branch}`);
37041
- await exec.exec('git', ['push', '--verbose', 'origin', branch], { silent: false });
37040
+ await exec.exec('git', ['push', '--force', '-- verbose', 'origin', branch], { silent: false });
37042
37041
if (!autoMerge) {
37043
37042
const octokit = github.getOctokit(token);
37044
37043
await createPR(octokit, owner, repo, branch, github.context.ref.replace('refs/heads/', ''), true);
@@ -37197,6 +37196,7 @@ async function branchExists(owner, repo, branchName, octokit) {
37197
37196
async function setupBranch(branchName, exists) {
37198
37197
try {
37199
37198
if (exists) {
37199
+ await exec.exec('git', ['fetch', 'origin']);
37200
37200
core.info(`Branch ${branchName} exists. Checking it out.`);
37201
37201
await exec.exec('git', ['checkout', branchName]);
37202
37202
await exec.exec('git', ['pull', 'origin', branchName], { silent: true });
@@ -37314,9 +37314,10 @@ async function updatePR(octokit, owner, repo, prNumber) {
37314
37314
// Create a new PR
37315
37315
async function createPR(octokit, owner, repo, branchName, targetBranch, isFromFern) {
37316
37316
core.info(`Creating new PR from ${branchName} to ${targetBranch}`);
37317
+ const date = new Date().toISOString().replace(/[:.]/g, '-');
37317
37318
let prTitle = isFromFern ?
37318
- ' Update API specifications with fern api update' :
37319
- ' Update OpenAPI specifications' ;
37319
+ `chore: Update API specifications with fern api update (${date})` :
37320
+ `chore: Update OpenAPI specifications (${date})` ;
37320
37321
let prBody = isFromFern ?
37321
37322
'Update API specifications by running fern api update.' :
37322
37323
'Update OpenAPI specifications based on changes in the source repository.';
0 commit comments