Skip to content

Commit eff311e

Browse files
authored
Add GitHub Actions for CI (#9)
1 parent 1de4f38 commit eff311e

File tree

5 files changed

+127
-87
lines changed

5 files changed

+127
-87
lines changed

.eslintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 2020,
4+
"impliedStrict": true,
5+
"sourceType": "module",
6+
"ecmaFeatures": {
7+
"impliedStrict": true,
8+
"experimentalObjectRestSpread": true
9+
}
10+
},
11+
"plugins": [
12+
"prettier"
13+
],
14+
"rules": {
15+
"prettier/prettier": "error"
16+
}
17+
}

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Node.js CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
matrix:
11+
node-version: [8.x, 10.x, 12.x, 14.x]
12+
13+
env:
14+
CI: true
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- run: npm ci
22+
- run: npm test
23+
- run: npm run lint

create-or-update-files.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function (octokit, opts) {
1+
module.exports = function(octokit, opts) {
22
return new Promise(async (resolve, reject) => {
33
// Up front validation
44
try {
@@ -19,7 +19,7 @@ module.exports = function (octokit, opts) {
1919
base,
2020
branch: branchName,
2121
createBranch,
22-
changes,
22+
changes
2323
} = opts;
2424

2525
let branchAlreadyExists = true;
@@ -43,7 +43,7 @@ module.exports = function (octokit, opts) {
4343
base = (
4444
await octokit.repos.get({
4545
owner,
46-
repo,
46+
repo
4747
})
4848
).data.default_branch;
4949
}
@@ -100,7 +100,7 @@ module.exports = function (octokit, opts) {
100100
path: fileName,
101101
sha: null, // sha as null implies that the file should be deleted
102102
mode: "100644",
103-
type: "commit",
103+
type: "commit"
104104
});
105105
}
106106
}
@@ -129,7 +129,7 @@ module.exports = function (octokit, opts) {
129129
path: fileName,
130130
sha: fileSha,
131131
mode: mode,
132-
type: type,
132+
type: type
133133
});
134134
}
135135

@@ -176,7 +176,7 @@ module.exports = function (octokit, opts) {
176176
repo,
177177
force: true,
178178
ref: `${updateRefBase}heads/${branchName}`,
179-
sha: baseTree,
179+
sha: baseTree
180180
});
181181

182182
// Return the new branch name so that we can use it later
@@ -195,7 +195,7 @@ async function fileExistsInRepo(octokit, owner, repo, path, branch) {
195195
owner,
196196
repo,
197197
path,
198-
ref: branch,
198+
ref: branch
199199
});
200200
return true;
201201
} catch (e) {
@@ -210,7 +210,7 @@ async function createCommit(octokit, owner, repo, message, tree, baseTree) {
210210
repo,
211211
message,
212212
tree: tree.sha,
213-
parents: [baseTree],
213+
parents: [baseTree]
214214
})
215215
).data;
216216
}
@@ -221,7 +221,7 @@ async function createTree(octokit, owner, repo, treeItems, baseTree) {
221221
owner,
222222
repo,
223223
tree: treeItems,
224-
base_tree: baseTree,
224+
base_tree: baseTree
225225
})
226226
).data;
227227
}
@@ -235,7 +235,7 @@ async function createBlob(octokit, owner, repo, contents, type) {
235235
owner,
236236
repo,
237237
content: Buffer.from(contents).toString("base64"),
238-
encoding: "base64",
238+
encoding: "base64"
239239
})
240240
).data;
241241
return file.sha;
@@ -247,7 +247,7 @@ async function loadRef(octokit, owner, repo, ref) {
247247
const x = await octokit.git.getRef({
248248
owner,
249249
repo,
250-
ref: `heads/${ref}`,
250+
ref: `heads/${ref}`
251251
});
252252
return x.data.object.sha;
253253
} catch (e) {

0 commit comments

Comments
 (0)