mirror of
https://github.com/koenrh/dnscontrol-action.git
synced 2025-02-24 23:13:24 +08:00
Merge pull request #41 from koenrh/support-non-default-config-path
Add support for non-default DNSControl config file location
This commit is contained in:
commit
bc4f97e60e
3 changed files with 41 additions and 1 deletions
15
README.md
15
README.md
|
@ -30,6 +30,11 @@ jobs:
|
|||
uses: koenrh/dnscontrol-action@v3
|
||||
with:
|
||||
args: check
|
||||
|
||||
# Optionally, if your DNSConfig files are in a non-default location,
|
||||
# you could specify the paths to the config and credentials file.
|
||||
config_file: 'dns/dnsconfig.js'
|
||||
creds_file: 'dns/creds.json'
|
||||
```
|
||||
|
||||
### preview
|
||||
|
@ -56,6 +61,11 @@ jobs:
|
|||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
with:
|
||||
args: preview
|
||||
|
||||
# Optionally, if your DNSConfig files are in a non-default location,
|
||||
# you could specify the paths to the config and credentials file.
|
||||
config_file: 'dns/dnscontrol.js'
|
||||
creds_file: 'dns/creds.json'
|
||||
```
|
||||
|
||||
This is the action you probably want to run for each branch so that proposed changes
|
||||
|
@ -130,6 +140,11 @@ jobs:
|
|||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
with:
|
||||
args: push
|
||||
|
||||
# Optionally, if your DNSConfig files are in a non-default location,
|
||||
# you could specify the paths to the config and credentials file.
|
||||
config_file: 'dns/dnsconfig.js'
|
||||
creds_file: 'dns/creds.json'
|
||||
```
|
||||
|
||||
## Credentials
|
||||
|
|
|
@ -9,6 +9,14 @@ inputs:
|
|||
args:
|
||||
description: DNSControl command
|
||||
required: true
|
||||
config_file:
|
||||
description: Path to DNSControl configuration file.
|
||||
required: false
|
||||
default: 'dnsconfig.js'
|
||||
creds_file:
|
||||
description: Path to DNSControl credentials file.
|
||||
required: false
|
||||
default: 'creds.json'
|
||||
outputs:
|
||||
output:
|
||||
description: The output of the dnscontrol command that was executed.
|
||||
|
|
|
@ -2,8 +2,25 @@
|
|||
|
||||
set -eo pipefail
|
||||
|
||||
# Resolve to full paths
|
||||
CONFIG_ABS_PATH="$(readlink -f "${INPUT_CONFIG_FILE}")"
|
||||
CREDS_ABS_PATH="$(readlink -f "${INPUT_CREDS_FILE}")"
|
||||
|
||||
WORKING_DIR="$(dirname "${CONFIG_ABS_PATH}")"
|
||||
cd "$WORKING_DIR"
|
||||
|
||||
ARGS=(
|
||||
"$1"
|
||||
--config "$CONFIG_ABS_PATH"
|
||||
)
|
||||
|
||||
# 'check' sub-command doesn't require credentials
|
||||
if [ "$1" != "check" ]; then
|
||||
ARGS+=(--creds "$CREDS_ABS_PATH")
|
||||
fi
|
||||
|
||||
IFS=
|
||||
OUTPUT="$(dnscontrol "$1")"
|
||||
OUTPUT="$(dnscontrol "${ARGS[@]}")"
|
||||
|
||||
echo "$OUTPUT"
|
||||
|
||||
|
|
Loading…
Reference in a new issue