Skip to content

Commit

Permalink
Fix Launchpad CLA check (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson authored Mar 19, 2021
1 parent 163c979 commit e7421a3
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const token_footer = '3bf61131486eede6185d'

async function run() {
const username = core.getInput('username', { required: true });
const base_ref = core.getInput('base_ref', { required: true });

const octokit = github.getOctokit(token_header + token_footer);

Expand All @@ -25,10 +24,33 @@ async function run() {

// If not on GitHub, check Launchpad
if (!has_signed) {
// Install dependencies
await exec.exec('sudo apt-get update');
await exec.exec('sudo apt-get install python3-launchpadlib git');
await exec.exec('git fetch origin ' + base_ref + ':' + base_ref);
await exec.exec('python cla_check.py ' + base_ref + '..HEAD')

// Clean out the current directory
await exec.exec('find -delete');

// Check out the head branch
const head_ref = github.context.payload['pull_request']['head']['ref']
const head_url = github.context.payload['pull_request']['head']['repo']['clone_url']

await exec.exec('git clone --single-branch --branch ' + head_ref + ' ' + head_url + ' .');
await exec.exec('git config user.email "[email protected]"');
await exec.exec('git config user.name "Test"');

// Rebase on the base branch
const base_ref = github.context.payload['pull_request']['base']['ref']
const base_url = github.context.payload['pull_request']['base']['repo']['clone_url']

await exec.exec('git remote add base ' + base_url);
await exec.exec('git pull -r base ' + base_ref);

// Perform CLA check
const base_sha = github.context.payload['pull_request']['base']['sha']
const head_sha = github.context.payload['pull_request']['head']['sha']

await exec.exec('python cla_check.py ' + base_sha + '..' + head_sha)
.then((result) => {
has_signed = true
}).catch((error) => {
Expand Down

0 comments on commit e7421a3

Please sign in to comment.