Last active
July 8, 2022 07:17
-
-
Save jaemyeong/82c87931d8a66a7c0f76529ac1f5fb90 to your computer and use it in GitHub Desktop.
DigitalOcean DNS Update
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
#!/usr/bin/env zx | |
import os from 'os'; | |
$.verbose = false; | |
const networkInterfaces = os.networkInterfaces(); | |
const externalAddress = Object.values(networkInterfaces).flatMap(value => value).find(value => value.family === 'IPv4' && value.internal === false).address; | |
echo`${externalAddress}`; | |
const response = await fetch(`https://api.digitalocean.com/v2/domains/${argv.domainName}/records/${argv.recordId}`, { | |
method: 'PATCH', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer ${argv.token}` | |
}, | |
body: JSON.stringify({ | |
data: externalAddress | |
}) | |
}) | |
echo`${response.status}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment