-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Magic tidying fairy (∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。゚,
- Loading branch information
Showing
1 changed file
with
59 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,59 @@ | ||
const fetch = require("node-fetch") | ||
|
||
const url = `https://${process.env.SPACES_BUCKET}.${process.env.SPACES_REGION}.digitaloceanspaces.com/${process.env.COMMIT_SHA}` | ||
|
||
const comment = `This commit has been deployed to DigitalOcean Spaces for easy viewing. ([DNS Tool](${url}/dns-tool/index.html), [SPF Explainer](${url}/spf-explainer/index.html))` | ||
|
||
fetch( | ||
`https://api.github.com/repos/do-community/dns-tool/commits/${process.env.COMMIT_SHA}/comments`, | ||
{ | ||
method: "POST", | ||
body: JSON.stringify({ | ||
body: comment, | ||
}), | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/vnd.github.v3+json", | ||
Authorization: `Basic ${Buffer.from(`github-actions:${process.env.GITHUB_ACCESS_TOKEN}`).toString("base64")}`, | ||
} | ||
}, | ||
).then(async x => { | ||
if (!x.ok) { console.log(await x.json()); process.exit(1); } | ||
}).catch(async e => { console.log(await e.json()); process.exit(1); }) | ||
/* | ||
Copyright 2019 DigitalOcean | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
const fetch = require('node-fetch') | ||
const path = require('path') | ||
const { readdirSync } = require('fs') | ||
|
||
const main = async () => { | ||
|
||
const baseURL = `https://${process.env.SPACES_BUCKET}.${process.env.SPACES_REGION}.digitaloceanspaces.com/${process.env.COMMIT_SHA}` | ||
|
||
const tools = readdirSync(path.join(__dirname, '..', 'dist'), { withFileTypes: true }) | ||
.filter(dirent => dirent.isDirectory()) | ||
.map(dirent => dirent.name) | ||
.map(name => `[${name}](${baseURL}/${name}/index.html)`) | ||
|
||
const comment = `This commit has been deployed to DigitalOcean Spaces for easy reviewing. | ||
| ${tools.join(' | ')} | | ||
|${(new Array(tools.length).fill('---')).join('|')}|` | ||
|
||
const res = await fetch( | ||
`https://api.github.com/repos/do-community/dns-tool/commits/${process.env.COMMIT_SHA}/comments`, | ||
{ | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
body: comment, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/vnd.github.v3+json', | ||
Authorization: `Basic ${Buffer.from(`github-actions:${process.env.GITHUB_ACCESS_TOKEN}`).toString('base64')}`, | ||
} | ||
}, | ||
).catch(async e => { | ||
console.log(await e.json()) | ||
process.exit(1) | ||
}) | ||
|
||
if (!res.ok) { | ||
console.log(await res.json()) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
main() |
6a0a2d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been deployed to DigitalOcean Spaces for easy reviewing.