Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update hare5.json #5793

Update hare5.json

Update hare5.json #5793

Workflow file for this run

name: Deploy DNS Records
on:
push:
branches:
- main # Or your default branch
paths:
- "records/**.json" # Be specific about JSON files
workflow_dispatch: # Allows manual triggering
jobs:
deploy:
runs-on: ubuntu-latest
# Add permissions for the GITHUB_TOKEN if needed by change detection methods that use the API
# permissions:
# contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
# Fetch depth 2 is needed to diff HEAD with the previous commit (HEAD^)
with:
fetch-depth: 2
- name: Identify Changes
id: changes
run: |
# Ensure we are on the main branch after checkout
git checkout ${{ github.ref_name }}
# Get lists of added, modified, deleted files ending in .json within records/
ADDED_FILES=$(git diff --name-status --diff-filter=A HEAD^ HEAD -- 'records/**.json' | cut -f2 | tr '\n' ' ')
MODIFIED_FILES=$(git diff --name-status --diff-filter=M HEAD^ HEAD -- 'records/**.json' | cut -f2 | tr '\n' ' ')
DELETED_FILES=$(git diff --name-status --diff-filter=D HEAD^ HEAD -- 'records/**.json' | cut -f2 | tr '\n' ' ')
echo "Added: $ADDED_FILES"
echo "Modified: $MODIFIED_FILES"
echo "Deleted: $DELETED_FILES"
echo "added_files=$ADDED_FILES" >> $GITHUB_OUTPUT
echo "modified_files=$MODIFIED_FILES" >> $GITHUB_OUTPUT
echo "deleted_files=$DELETED_FILES" >> $GITHUB_OUTPUT
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm" # Cache dependencies
- name: Install Dependencies
run: npm install cloudflare typescript # Install Cloudflare client and TypeScript
- name: Compile TypeScript
run: npx tsc -p .github/scripts/tsconfig.json
- name: Update DNS via Cloudflare API
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
ADDED_FILES: ${{ steps.changes.outputs.added_files }}
MODIFIED_FILES: ${{ steps.changes.outputs.modified_files }}
DELETED_FILES: ${{ steps.changes.outputs.deleted_files }}
GITHUB_WORKSPACE: ${{ github.workspace }} # Pass workspace path
BASE_DOMAIN: "is-an.ai" # Define your base domain here
run: node .github/scripts/update-cloudflare-dns.js # Execute the compiled script