Expanded CF DNS setup.
This commit is contained in:
@@ -43,33 +43,43 @@ jobs:
|
|||||||
- name: Setup yq
|
- name: Setup yq
|
||||||
uses: dcarbone/install-yq-action@v1
|
uses: dcarbone/install-yq-action@v1
|
||||||
|
|
||||||
- name: Setup go
|
- name: Grab subdomains from Compose
|
||||||
uses: WillAbides/setup-go-faster@v1.14.0
|
id: compose-domains
|
||||||
with:
|
|
||||||
go-version: 'stable'
|
|
||||||
|
|
||||||
- name: Subdomain Check/Creation
|
|
||||||
id: domain-check
|
|
||||||
env:
|
env:
|
||||||
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: |
|
||||||
echo "Installing flarectl..."
|
yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}') > compose_subdomains.txt
|
||||||
if [ -z $(go env GOBIN) ]; then
|
|
||||||
export GOBIN=${{ github.workspace }}
|
- name: Retrieve subdomains in Cloudflare
|
||||||
|
uses: addnab/docker-run-action@v3
|
||||||
|
with:
|
||||||
|
image: quay.io/aminvakil/flarectl:latest
|
||||||
|
options: -v ${{ github.workspace }}:/workspace -e CF_API_KEY=${{ secrets.CF_API_TOKEN }} -e CF_API_EMAIL=${{ secrets.CF_API_EMAIL }}
|
||||||
|
run: |
|
||||||
|
--json dns list --zone ${{ secrets.CF_ZONE_ID }} --type CNAME --content "trez.wtf" | jq '.[].Name' | sed -e 's|.trez.wtf||g' -e 's|"||g' | sort -u > cloudflare_subdomains.txt
|
||||||
|
|
||||||
|
- name: Compare & Create Missing Subdomains
|
||||||
|
id: compare-subdomains
|
||||||
|
run: |
|
||||||
|
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
|
fi
|
||||||
go install github.com/cloudflare/cloudflare-go/cmd/flarectl@latest 2>&1
|
cat > ${{ github.workspace }}/cloudflare.env <<EOF
|
||||||
echo "Grabbing most up-to-date subdomain list from Cloudflare..."
|
CF_API_KEY=${{ secrets.CF_API_TOKEN }}
|
||||||
./flarectl d l --zone trez.wtf --type CNAME --content trez.wtf | egrep -v 'ID' | awk '{print $5}' > cf_subdomain_list.txt
|
CF_API_EMAIL=${{ secrets.CF_API_EMAIL }}
|
||||||
swag_urls=$(yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}')
|
EOF
|
||||||
for subdomain in $(echo ${swag_urls}); do
|
for subdomain in $(cat missing_subdomains.txt); do
|
||||||
if grep -q ${subdomain} cf_subdomain_list.txt; then
|
echo "Adding ${subdomain} to Cloudflare..."
|
||||||
echo "Subdomain ${subdomain}.trez.wtf already exists in Cloudflare. Skipping..."
|
docker run -it --rm --env-file cloudflare.env quay.io/aminvakil/flarectl:latest dns creeate --zone ${{ secrets.CF_ZONE_ID }} --type CNAME --name "${subdomain}" --content "trez.wtf" --proxy true
|
||||||
else
|
|
||||||
echo "Subdomain ${subdomain}.trez.wtf does not exist in Cloudflare. Creating..."
|
|
||||||
flarectl d c --zone trez.wtf --name ${subdomain} --type CNAME --content trez.wtf --proxy
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# docker-compose-test:
|
# docker-compose-test:
|
||||||
# name: Docker Compose Test
|
# name: Docker Compose Test
|
||||||
|
|||||||
Reference in New Issue
Block a user