Skip to content

Commit d87cdb8

Browse files
committed
Render DNS address from secret
1 parent b38b68b commit d87cdb8

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

.github/workflows/dns.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,30 @@ jobs:
2424
NAMECHEAP_API_KEY: ${{ secrets.NAMECHEAP_API_KEY }}
2525
NAMECHEAP_USERNAME: ${{ secrets.NAMECHEAP_USERNAME }}
2626
NAMECHEAP_CLIENT_IP: ${{ secrets.NAMECHEAP_CLIENT_IP }}
27+
SITE_SERVER_IP: ${{ secrets.SITE_SERVER_IP || secrets.SERVER_IP || secrets.DEPLOY_SERVER_IP }}
2728
steps:
2829
- uses: actions/checkout@v4
2930
- uses: actions/setup-python@v5
3031
with:
3132
python-version: '3.12'
3233
- name: Install npmctl from PyPI
3334
run: python -m pip install --upgrade npmctl npmctl-namecheap
35+
- name: Render DNS desired state
36+
shell: bash
37+
run: |
38+
if [ -z "${SITE_SERVER_IP}" ]; then
39+
echo "Set SITE_SERVER_IP, SERVER_IP, or DEPLOY_SERVER_IP secret for DNS A records."
40+
exit 1
41+
fi
42+
mkdir -p .tmp
43+
sed "s/__SITE_SERVER_IP__/${SITE_SERVER_IP}/g" desired-state/dns.yaml > .tmp/dns.yaml
3444
- name: Validate desired DNS state
35-
run: npmctl validate desired-state/dns.yaml
45+
run: npmctl validate .tmp/dns.yaml
3646
- name: Validate Namecheap provider
3747
run: npmctl dns doctor --provider namecheap
3848
- name: Plan Namecheap DNS with npmctl
3949
if: ${{ github.event.inputs.mode != 'apply' }}
40-
run: npmctl plan desired-state/dns.yaml --owner npmctl-com
50+
run: npmctl plan .tmp/dns.yaml --owner npmctl-com
4151
- name: Apply Namecheap DNS with npmctl
4252
if: ${{ github.event.inputs.mode == 'apply' }}
43-
run: npmctl apply desired-state/dns.yaml --owner npmctl-com
53+
run: npmctl apply .tmp/dns.yaml --owner npmctl-com

desired-state/dns.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dns_records:
66
zone: npmctl.com
77
type: A
88
name: "@"
9-
value: 149.255.33.251
9+
value: __SITE_SERVER_IP__
1010
ttl: 300
1111
meta:
1212
managed_by: npmctl

0 commit comments

Comments
 (0)