octodemo / awesome-actions

Repository template used to showcase Actions that tie into pull request and issue events
109 stars 24 forks source link

Test PR #62

Closed jonico closed 4 years ago

jonico commented 4 years ago

@github-actions run

🚀 Merge preview ```js // Get pull-req URL like "https://api.github.com/repos/nwtgck/actions-merge-preview/pulls/4" const pullReqUrl = context.payload.issue.pull_request.url; const githubUser = context.payload.repository.owner.login; const res = await fetch(pullReqUrl, { headers: [ ['Authorization', `Basic ${Buffer.from(`${githubUser}:${githubToken}`).toString('base64')}`] ] }); const resJson = await res.json(); const prUserName = resJson.head.user.login; const baseBranchName = resJson.base.ref; const branchName = resJson.head.ref; const fullRepoName = resJson.head.repo.full_name; const previewBranchName = `actions-merge-preview/${prUserName}-${branchName}`; execSync(`git config --global user.email "github-actions[bot]@users.noreply.github.com"`); execSync(`git config --global user.name "github-actions[bot]"`); // (from: https://stackoverflow.com/a/23987039/2885946) execSync(`git fetch --all`); console.log(execSync(`git checkout ${baseBranchName}`).toString()); console.log(execSync(`git checkout -b ${previewBranchName} ${baseBranchName}`).toString()); console.log(execSync(`git pull https://github.com/${fullRepoName}.git ${branchName}`).toString()); // Push preview branch // NOTE: Force push (should be safe because preview branch always start with "actions-merge-preview/") execSync(`git push -fu origin ${previewBranchName}`); const baseRepoFullName = context.payload.repository.full_name; // Comment body const commentBody = `🚀 Preview branch: \n`; // Comment the deploy URL await postComment(commentBody); ```
github-actions[bot] commented 4 years ago

🚀 Preview branch:
https://github.com/octodemo/awesome-actions/tree/actions-merge-preview/jonico-stale-fix