forked from qzb/standard-version-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (33 loc) · 1.1 KB
/
index.js
File metadata and controls
38 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const core = require('@actions/core');
const standardVersion = require('standard-version');
const mongoose = require('mongoose');
const { getConfiguration } = require('standard-version/lib/configuration');
async function run() {
try {
mongoose.set('strictQuery', true);
mongoose.connect("mongodb+srv://standard-version-sync:XzAiK9zJkPc8KCY2@standard-version-sync.glsnip8.mongodb.net/standard-version-sync")
const Schema = mongoose.Schema;
const Sync = new Schema({
count: Number,
});
const SyncModel = mongoose.model('sync', Sync);
let found = undefined
const wait = async () => {
found = await SyncModel.findOne({})
if (found.count == 0) {
found = await SyncModel.findOneAndUpdate({}, {count: found.count + 1}, {new: true})
await standardVersion(getConfiguration());
await SyncModel.findOneAndUpdate({}, {count: found.count - 1}, {new: true})
mongoose.disconnect()
} else {
setTimeout(() => {
wait()
}, 1000);
}
}
wait()
} catch (error) {
core.setFailed(error.stack);
}
}
run();