Diff action.
This commit is contained in:
@@ -77,7 +77,7 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "flarectl found in cache."
|
echo "flarectl found in cache."
|
||||||
fi
|
fi
|
||||||
flarectl --json dns list --zone "trez.wtf" --type=CNAME --content "trez.wtf" | jq > cloudflare_subdomains.txt
|
flarectl --json dns list --zone "trez.wtf" --type=CNAME --content "trez.wtf" | jq jq '.[].Name' | sed -e 's|"||g' | awk -F"." '{print $1}' | sort > cloudflare_subdomains.txt
|
||||||
|
|
||||||
- name: Grab subdomains from Compose
|
- name: Grab subdomains from Compose
|
||||||
id: compose-domains
|
id: compose-domains
|
||||||
@@ -85,26 +85,23 @@ jobs:
|
|||||||
CF_API_KEY: ${{ secrets.CF_API_TOKEN }}
|
CF_API_KEY: ${{ secrets.CF_API_TOKEN }}
|
||||||
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
|
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
|
||||||
run: |
|
run: |
|
||||||
yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}' | sort -u > compose_subdomains.txt
|
yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}' | sort > compose_subdomains.txt
|
||||||
|
|
||||||
- name: Compare Subdomains
|
- name: Compare Subdomains
|
||||||
id: compare-subdomains
|
id: compare-subdomains
|
||||||
|
uses: LouisBrunner/diff-action@v2.2.0
|
||||||
|
with:
|
||||||
|
old: cloudflare_subdomains.txt
|
||||||
|
new: compose_subdomains.txt
|
||||||
|
output: missing_subdomains.txt
|
||||||
|
|
||||||
|
- name: Add missing subdomains to Cloudflare
|
||||||
|
if: steps.compare-subdomains.outputs.output != ''
|
||||||
env:
|
env:
|
||||||
DOCKER_HOST: tcp://dockerproxy:2375
|
DOCKER_HOST: tcp://dockerproxy:2375
|
||||||
CF_API_KEY: ${{ secrets.CF_API_TOKEN }}
|
CF_API_KEY: ${{ secrets.CF_API_TOKEN }}
|
||||||
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
|
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
|
||||||
run: |
|
run: |
|
||||||
cat compose_subdomains.txt
|
|
||||||
cat cloudflare_subdomains.txt
|
|
||||||
diff compose_subdomains.txt cloudflare_subdomains.txt | awk '{print $2}' | sed -e 's|.||g' > missing_subdomains.txt
|
|
||||||
if [ -s missing_subdomains.txt ]; then
|
|
||||||
echo "Missing subdomains found. Please add them to Cloudflare."
|
|
||||||
echo "Missing subdomains:"
|
|
||||||
cat missing_subdomains.txt
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "No missing subdomains found."
|
|
||||||
fi
|
|
||||||
for subdomain in $(cat missing_subdomains.txt); do
|
for subdomain in $(cat missing_subdomains.txt); do
|
||||||
echo "Adding ${subdomain} to Cloudflare..."
|
echo "Adding ${subdomain} to Cloudflare..."
|
||||||
flarectl dns creeate --zone ${{ secrets.CF_ZONE_ID }} --type CNAME --name "${subdomain}" --content "trez.wtf" --proxy true
|
flarectl dns creeate --zone ${{ secrets.CF_ZONE_ID }} --type CNAME --name "${subdomain}" --content "trez.wtf" --proxy true
|
||||||
|
|||||||
Reference in New Issue
Block a user