From 249a23d7703b5ced46f0dee9bd0128afa2245cb1 Mon Sep 17 00:00:00 2001 From: devStorm <59678453+developStorm@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:25:52 -0700 Subject: [PATCH] build(ci): update anchors with action --- .github/workflows/update-xml.yml | 29 +++++++++++++++++++++++++++++ rootanchors.go | 5 +++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/update-xml.yml diff --git a/.github/workflows/update-xml.yml b/.github/workflows/update-xml.yml new file mode 100644 index 0000000..077ef55 --- /dev/null +++ b/.github/workflows/update-xml.yml @@ -0,0 +1,29 @@ +name: Update Root Zone Trust Anchors + +on: + schedule: + - cron: "5 4 * * *" + workflow_dispatch: + +jobs: + update-xml: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Update XML in Go file + run: | + xml_content=$(curl -sSL https://data.iana.org/root-anchors/root-anchors.xml | sed -e 's/[\/&]/\\&/g' -e ':a;N;$!ba;s/\n/\\n/g') + sed -i '/\/\/ BEGIN IANA ROOT ANCHORS XML DATA/,/\/\/ END XML DATA/c\// BEGIN IANA ROOT ANCHORS XML DATA\nconst IanaRootAnchorsXml = `'"$xml_content"'`\n\n// END XML DATA' rootanchors.go + cat rootanchors.go + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "chore: update root zone trust anchors" + title: Update Root Zone Trust Anchors + body: | + This PR updates root zone trust anchors XML. Please verify the changes. + branch: update-xml diff --git a/rootanchors.go b/rootanchors.go index 4c7f391..6e15ba1 100644 --- a/rootanchors.go +++ b/rootanchors.go @@ -9,7 +9,8 @@ import ( // https://data.iana.org/root-anchors/root-anchors.xml // BEGIN IANA ROOT ANCHORS XML DATA -const ianaRootAnchorsXml = ` + +const IanaRootAnchorsXml = ` . @@ -58,7 +59,7 @@ type KeyDigest struct { func GetRawAnchors() TrustAnchor { var ta TrustAnchor - xml.Unmarshal([]byte(ianaRootAnchorsXml), &ta) + xml.Unmarshal([]byte(IanaRootAnchorsXml), &ta) return ta }