Skip to content
This repository was archived by the owner on Apr 18, 2020. It is now read-only.

Commit c182604

Browse files
committed
Fixed GitHub webhook being set all the time due to OAuth token
1 parent 656b3da commit c182604

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1919
# IN THE SOFTWARE.
2020

21-
all: clean lint | build
21+
all: lint | build
2222

2323
# -----------------------------------------------------------------------------
2424
# Prerequisites

aws-lambda/.eslintignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@
2020

2121
# Distribution files
2222
/dist
23-
24-
# ES5 files
25-
/webpack.config.js

aws-lambda/src/status.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default (event, context, cb) => {
138138
return new Promise((resolve, reject) => {
139139
if (ref === "master" && BADGES[state]) {
140140
s3.putObject({
141-
Bucket: process.env.STATUS_BUCKET,
141+
Bucket: process.env.CODEBUILD_BUCKET,
142142
Key: `${repo}/status.svg`,
143143
Body: BADGES[state],
144144
ACL: "public-read",

aws-lambda/webpack.config.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ const EventHooksPlugin = require("event-hooks-webpack-plugin")
3939
* @return {Array<string>} Paths of dependent modules
4040
*/
4141
const resolve = module => {
42-
const package = require(path.resolve(module, "package.json"))
43-
return Object.keys(package.dependencies || {}).reduce(
42+
const metadata = require(path.resolve(module, "package.json"))
43+
return Object.keys(metadata.dependencies || {}).reduce(
4444
(dependencies, name) => {
4545
const dependency = path.resolve([module, __dirname].find(base => {
4646
return fs.existsSync(path.resolve(base, "node_modules", name))
4747
}), "node_modules", name)
4848
return [...dependencies, dependency, ...resolve(dependency)]
49-
},
50-
[])
49+
}, [])
5150
}
5251

5352
/* ----------------------------------------------------------------------------
@@ -59,7 +58,7 @@ module.exports = {
5958

6059
/* Entrypoints */
6160
entry: {
62-
push: path.resolve(__dirname, "src/push.js"),
61+
push: path.resolve(__dirname, "src/push.js"),
6362
status: path.resolve(__dirname, "src/status.js")
6463
},
6564

@@ -90,7 +89,7 @@ module.exports = {
9089

9190
/* Post-compilation hook to bundle sources with dependencies */
9291
new EventHooksPlugin({
93-
'done': stats => {
92+
done: stats => {
9493
Object.keys(stats.compilation.entrypoints).forEach(name => {
9594
const entrypoint = stats.compilation.entrypoints[name]
9695
entrypoint.chunks.forEach(chunk => {
@@ -106,15 +105,15 @@ module.exports = {
106105

107106
/* Bundle all non-native modules, except aws-sdk */
108107
if (dependency.request && dependency.request !== "aws-sdk" &&
109-
dependency.request.match(/^[^\.]/)) {
108+
dependency.request.match(/^[^.]/)) {
110109
const external = path.resolve(
111110
__dirname, "node_modules", dependency.request)
112111
if (fs.existsSync(external)) {
113112
archive.directory(external,
114113
path.join("node_modules", dependency.request))
115114

116115
/* Bundle nested dependencies */
117-
resolve(external).map(subexternal => {
116+
resolve(external).forEach(subexternal => {
118117
archive.directory(subexternal,
119118
path.relative(__dirname, subexternal))
120119
})
@@ -124,7 +123,7 @@ module.exports = {
124123
})
125124

126125
/* Append compiled sources to archive */
127-
archive.directory(path.resolve(__dirname, "dist", name), false);
126+
archive.directory(path.resolve(__dirname, "dist", name), false)
128127

129128
/* Finalize and write archive */
130129
archive.pipe(zipfile)

main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ resource "aws_lambda_function" "webhook_status" {
309309
variables = {
310310
GITHUB_OAUTH_TOKEN = "${var.github_oauth_token}"
311311
GITHUB_REPORTER = "${var.github_reporter}"
312-
STATUS_BUCKET = "${aws_s3_bucket.codebuild.bucket}"
312+
CODEBUILD_BUCKET = "${aws_s3_bucket.codebuild.bucket}"
313313
}
314314
}
315315
}
@@ -340,4 +340,9 @@ resource "github_repository_webhook" "webhook" {
340340
}
341341

342342
events = ["push", "pull_request"]
343+
344+
# Ignore, if the webhook already exists
345+
lifecycle {
346+
ignore_changes = ["*"]
347+
}
343348
}

0 commit comments

Comments
 (0)