mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-22 07:20:06 +00:00
CI: revise change detection logic ... (#5943)
... now determines whether the last commit was push during the 24 hour time-frame
This commit is contained in:
parent
2fc7def6f6
commit
327d07d66f
29
.github/workflows/ci-merge.js
vendored
29
.github/workflows/ci-merge.js
vendored
@ -6,19 +6,30 @@ const fs = require("fs");
|
||||
const DETECTION_TIME_FRAME = (parseInt(process.env.DETECTION_TIME_FRAME)) || (24 * 3600 * 1000);
|
||||
|
||||
async function checkBaseChanges(github, context) {
|
||||
// a special robustness handling for when GHA did not pass the repository info
|
||||
if (!context.payload.repository) {
|
||||
const result = await github.rest.repos.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
context.payload.repository = result.data;
|
||||
}
|
||||
const delta = new Date() - new Date(context.payload.repository.pushed_at);
|
||||
// query the commit date of the latest commit on this branch
|
||||
const query = `query($owner:String!, $name:String!, $ref:String!) {
|
||||
repository(name:$name, owner:$owner) {
|
||||
ref(qualifiedName:$ref) {
|
||||
target {
|
||||
... on Commit { id pushedDate oid }
|
||||
}
|
||||
}
|
||||
}
|
||||
}`;
|
||||
const variables = {
|
||||
owner: context.repo.owner,
|
||||
name: context.repo.repo,
|
||||
ref: 'refs/heads/master',
|
||||
};
|
||||
const result = await github.graphql(query, variables);
|
||||
const pushedAt = result.repository.ref.target.pushedDate;
|
||||
console.log(`Last commit pushed at ${pushedAt}.`);
|
||||
const delta = new Date() - new Date(pushedAt);
|
||||
if (delta <= DETECTION_TIME_FRAME) {
|
||||
console.info('New changes detected, triggering a new build.');
|
||||
return true;
|
||||
}
|
||||
console.info('No new changes detected.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user