Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/vouch-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ jobs:
}
}

// Check the VOUCHED.td file. Read from the default branch, NOT the
// PR branch — the PR author could add themselves in their fork.
// Check the VOUCHED.td file on the dedicated "vouched" branch.
// NOT the PR branch — the PR author could add themselves in their fork.
let vouched = false;
try {
const { data } = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: '.github/VOUCHED.td',
ref: context.payload.repository.default_branch,
ref: 'vouched',
});
const content = Buffer.from(data.content, 'base64').toString('utf-8');
const usernames = content
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/vouch-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,33 @@ jobs:
// --- Read VOUCHED.td ---

const filePath = '.github/VOUCHED.td';
const branch = context.payload.repository.default_branch;
const branch = 'vouched';

// Ensure the "vouched" branch exists. If not, create it from main.
try {
await github.rest.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch,
});
} catch (e) {
if (e.status === 404) {
console.log('Creating "vouched" branch from main.');
const { data: mainRef } = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${context.payload.repository.default_branch}`,
});
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/heads/vouched',
sha: mainRef.object.sha,
});
} else {
throw e;
}
}

let currentContent = '';
let sha = '';
Expand All @@ -89,7 +115,7 @@ jobs:
currentContent = Buffer.from(data.content, 'base64').toString('utf-8');
sha = data.sha;
} catch (e) {
console.log(`Could not read VOUCHED.td: ${e.message}`);
console.log(`Could not read VOUCHED.td on "${branch}" branch: ${e.message}`);
return;
}

Expand Down
Loading