This commit is contained in:
2025-01-03 14:50:32 -05:00
parent c4b67c6b36
commit 43ddc8c743
+40 -38
View File
@@ -78,7 +78,7 @@ jobs:
version: '0.113.0' version: '0.113.0'
- name: Subdomain/CNAME Comparison & Creation - name: Subdomain/CNAME Comparison & Creation
id: compare-subdomains id: grab-subdomains
env: env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }} CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
@@ -88,46 +88,48 @@ jobs:
flarectl --json dns list --zone "trez.wtf" --type=CNAME --content "trez.wtf" | jq '.[].Name' | sed -e 's|"||g' | awk -F"." '{print $1}' | sort > cloudflare_subdomains.txt flarectl --json dns list --zone "trez.wtf" --type=CNAME --content "trez.wtf" | jq '.[].Name' | sed -e 's|"||g' | awk -F"." '{print $1}' | sort > cloudflare_subdomains.txt
echo "Grabbing subdomains from docker-compose.yml..." echo "Grabbing subdomains from docker-compose.yml..."
yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}' | sort > 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
which diff
diff compose_subdomains.txt cloudflare_subdomains.txt | egrep '<' | awk '{print $2}' > missing_subdomains.txt
cat missing_subdomains.txt
if [ -s missing_subdomains.txt ]; then
echo "Missing subdomains found. Creating them..."
while IFS= read -r subdomain; do
echo "Creating $subdomain.trez.wtf..."
flarectl dns create --zone "trez.wtf" --name "$subdomain" --type CNAME --content "trez.wtf"
done < missing_subdomains.txt
else
echo "No missing subdomains found."
fi
merge-pr: - name: Compare Subdomains and Create Missing Ones
name: PR Merge id: compare-subdomains
runs-on: ubuntu-latest uses: LouisBrunner/diff-action@v2.2.0
needs: [cloudflare-dns-setup]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Send Gotify Notification
uses: eikendev/gotify-action@0.0.3
with: with:
gotify_api_base: '${{ secrets.GOTIFY_URL }}' old: compose_subdomains.txt
gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}' new: cloudflare_subdomains.txt
notification_title: '${{ github.ref_name }} ready to be merged.' mode: 'addition'
notification_message: '${{ gitea.server_url }}/issues' tolerance: mixed-better
- name: Manual Approval - name: Create Missing Subdomains
uses: trstringer/manual-approval@v1 if: steps.compare-subdomains.outputs.output != ''
with: run: |
secret: ${{ secrets.BOT_GITEA_TOKEN }} echo ${{ steps.compare-subdomains.outputs.output }}
approvers: Trez.One
minimum-approvals: 1 # merge-pr:
issue-title: "Deployment of ${{ github.ref_name }}" # name: PR Merge
issue-body: "Autobots, roll out!" # runs-on: ubuntu-latest
exclude-workflow-initiator-as-approver: false # needs: [cloudflare-dns-setup]
additional-approved-words: '' # steps:
additional-denied-words: '' # - name: Checkout
# uses: actions/checkout@v4
# - name: Send Gotify Notification
# uses: eikendev/gotify-action@0.0.3
# with:
# gotify_api_base: '${{ secrets.GOTIFY_URL }}'
# gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}'
# notification_title: '${{ github.ref_name }} ready to be merged.'
# notification_message: '${{ gitea.server_url }}/issues'
# - name: Manual Approval
# uses: trstringer/manual-approval@v1
# with:
# secret: ${{ secrets.BOT_GITEA_TOKEN }}
# approvers: Trez.One
# minimum-approvals: 1
# issue-title: "Deployment of ${{ github.ref_name }}"
# issue-body: "Autobots, roll out!"
# exclude-workflow-initiator-as-approver: false
# additional-approved-words: ''
# additional-denied-words: ''
# - name: Tea CLI Setup & PR Merge # - name: Tea CLI Setup & PR Merge
# run: | # run: |