Skip to content

Commit

Permalink
feat: send a notification when the build workflow is completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed May 18, 2022
1 parent 53d90ab commit 1808766
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mkdocsPublisher/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class MkdocsPublication extends Plugin {
const publishSuccess =
await publish.publish(file, true);
if (publishSuccess) {
new Notice('Send "' + file.basename + '" to ' + this.settings.githubRepo + ".\nNow, waiting for the workflow to be completed...")
await publish.workflowGestion();
new Notice(
"Successfully published " +
Expand Down Expand Up @@ -83,6 +84,7 @@ export default class MkdocsPublication extends Plugin {
const publishSuccess =
await publish.publish(view.file, true);
if (publishSuccess) {
new Notice('Send "' + view.file.basename + '" to ' + this.settings.githubRepo + ".\nNow, waiting for the workflow to be completed...")
await publish.workflowGestion();
new Notice(
"Successfully published " +
Expand Down Expand Up @@ -127,6 +129,7 @@ export default class MkdocsPublication extends Plugin {
true
);
if (publishSuccess) {
new Notice('Send "' + currentFile.basename + '"to ' + this.settings.githubRepo + ".\nNow, waiting for the workflow to be completed...")
publishFile.workflowGestion();
new Notice(
"Successfully published " +
Expand Down Expand Up @@ -192,11 +195,16 @@ export default class MkdocsPublication extends Plugin {
}
statusBar.finish(8000);
new Notice(
`Successfully published ${
`Send ${
publishedFiles.length - errorCount
} notes to ${this.settings.githubRepo}`
);
await publish.workflowGestion();
new Notice(
`Successfully published ${
publishedFiles.length - errorCount
} notes to ${this.settings.githubRepo}.\nNow, waiting for the workflow to be completed...`
);
}
} catch (e) {
// statusBarItems.remove();
Expand Down
15 changes: 15 additions & 0 deletions mkdocsPublisher/utils/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ export default class MkdocsPublish {
workflow_id: 'ci.yml',
ref: 'main'
})
let finished = false;
while (!finished) {
await sleep(10000)
const workflowGet=await octokit.request('GET /repos/{owner}/{repo}/actions/runs', {
owner: this.settings.githubName,
repo: this.settings.githubRepo
});
if (workflowGet.data.workflow_runs.length > 0) {
const build = workflowGet.data.workflow_runs.find(run => run.name === 'ci')
if (build.status === 'completed') {
finished = true
}
}
}

}

async updateSettings () {
Expand Down

0 comments on commit 1808766

Please sign in to comment.