Skip to content

Commit

Permalink
Merge pull request #1 from XueMoMo/main
Browse files Browse the repository at this point in the history
fix getRecoders
  • Loading branch information
XueMoMo authored May 28, 2021
2 parents bb2691f + 6fb6ef7 commit 4bd881b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: rez0n/create-dns-record@v2.1
- uses: XueMoMo/[email protected].1
with:
name: "review.example.com"
cid: "Qmaosiodjjkfjaklsjdkjklfjklajskjdklf"
Expand Down
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "CloudFlare DNSLink"
description: "Creates and updates CloudFlare DNSLink"
description: "Creates or updates CloudFlare DNSLink"
author: "Xuemomo"

inputs:
Expand Down
12 changes: 4 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getCurrentRecordId = () => {
const { status, stdout } = cp.spawnSync("curl", [
...["--header", `Authorization: Bearer ${process.env.INPUT_TOKEN}`],
...["--header", "Content-Type: application/json"],
`https://api.cloudflare.com/client/v4/zones/${process.env.INPUT_ZONE}/dns_records`,
`https://api.cloudflare.com/client/v4/zones/${process.env.INPUT_ZONE}/dns_records?name=_dnslink.${process.env.INPUT_NAME}`,
]);

if (status !== 0) {
Expand All @@ -25,14 +25,10 @@ const getCurrentRecordId = () => {
process.exit(1);
}

const name = process.env.INPUT_NAME;
const record = result.find((x) => x.name === `_dnslink.${name}`);

if (!record) {
return null
if(result.length > 0){
return result[0].id
}

return record.id;
return null
};

const createRecord = () => {
Expand Down

0 comments on commit 4bd881b

Please sign in to comment.