Skip to content

Commit faa49b8

Browse files
authored
Merge pull request #61 from g0v-network/update-octodns
Updated octodns to get around a zone_id but that fails sync workflow
2 parents 29ac45f + cdc9e9c commit faa49b8

File tree

11 files changed

+290
-240
lines changed

11 files changed

+290
-240
lines changed

.github/workflows/domain-plan.yml

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
on:
22
pull_request_target:
33
paths:
4-
- '*.domain/*.yaml'
5-
- '.github/config-plan-amendment.yml'
6-
- '.github/workflows/domain-plan.yml'
4+
- "*.domain/*.yaml"
5+
- ".github/config-plan-amendment.yml"
6+
- ".github/workflows/domain-plan.yml"
7+
- "Pipfile*"
78

89
defaults:
910
run:
@@ -22,44 +23,15 @@ jobs:
2223
- name: Checkout config files from PR
2324
id: prhead
2425
run: |
25-
# Set $_sha to the first 7 char of PR head SHA
26-
_sha="$(echo "${{ github.event.pull_request.head.sha }}" | cut -c 1-7)"
27-
# Fetch PR head commit
28-
git fetch origin refs/pull/${{ github.event.pull_request.number }}/head
29-
# List changed config files in PR head
30-
_files="$(git diff --name-only HEAD $_sha | grep "\.yaml$")"
31-
# Separate added/modified files from deleted files
32-
_existing_files=""
33-
_deleted_files=""
34-
for file in $_files; do
35-
if git cat-file -e "$_sha:$file" 2>/dev/null; then
36-
_existing_files="$_existing_files $file"
37-
else
38-
_deleted_files="$_deleted_files $file"
39-
fi
40-
done
41-
# Checkout only existing config files from PR head commit
42-
if [ -n "$_existing_files" ]; then
43-
git checkout "$_sha" -- $_existing_files
44-
fi
45-
# Remove deleted files from working directory if they exist
46-
if [ -n "$_deleted_files" ]; then
47-
for file in $_deleted_files; do
48-
if [ -f "$file" ]; then
49-
echo "Removing deleted file: $file"
50-
rm "$file"
51-
fi
52-
done
53-
fi
54-
# Set output 'sha' to $_sha
55-
echo "::set-output name=sha::${_sha}"
26+
chmod +x scripts/checkout-pr-config-files.sh
27+
scripts/checkout-pr-config-files.sh "${{ github.event.pull_request.head.sha }}" "${{ github.event.pull_request.number }}"
5628
5729
- name: Force HTML plan output
5830
run: cat .github/config-plan-amendment.yml >> config.yaml
5931

6032
- uses: actions/setup-python@v2
6133
with:
62-
python-version: '3.8'
34+
python-version: "3.8"
6335

6436
- name: Install pipenv
6537
run: |
@@ -75,20 +47,15 @@ jobs:
7547
- name: Get plan output
7648
id: plan
7749
run: |
78-
# Parse plan output into $_plan
79-
_plan="$(cat ${GITHUB_WORKSPACE}/octodns-sync.plan)"
80-
_plan="${_plan//'%'/'%25'}"
81-
_plan="${_plan//$'\n'/'%0A'}"
82-
_plan="${_plan//$'\r'/'%0D'}"
83-
# Set output 'plan' to $_plan
84-
echo "::set-output name=plan::${_plan}"
50+
chmod +x scripts/parse-plan-output.sh
51+
scripts/parse-plan-output.sh "${GITHUB_WORKSPACE}/octodns-sync.plan"
8552
8653
- name: Find Comment
8754
uses: peter-evans/find-comment@v1
8855
id: find-comment
8956
with:
9057
issue-number: ${{ github.event.pull_request.number }}
91-
comment-author: 'github-actions[bot]'
58+
comment-author: "github-actions[bot]"
9259
body-includes: Automatically generated by octodns-sync
9360

9461
- name: Add or update PR comment

.github/workflows/domain-sync.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ on:
66
branches:
77
- main
88
paths:
9-
- '.github/workflows/domain-sync.yml'
10-
- '.github/settings.yml'
9+
- ".github/workflows/domain-sync.yml"
10+
- ".github/settings.yml"
1111
# Only domain folders ending in dots.
12-
- '*.domain/*.yaml'
13-
- 'config.yaml'
12+
- "*.domain/*.yaml"
13+
- "config.yaml"
14+
- "Pipfile*"
1415

1516
env:
1617
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
@@ -20,11 +21,11 @@ jobs:
2021
name: Publish DNS config from main
2122
runs-on: ubuntu-latest
2223
steps:
23-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v5
2425

25-
- uses: actions/setup-python@v2
26+
- uses: actions/setup-python@v6
2627
with:
27-
python-version: '3.8'
28+
python-version: "3.8"
2829

2930
- name: Install pipenv
3031
run: |

.github/workflows/sync-repo-settings.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ on:
44
workflow_dispatch:
55
push:
66
branches: [main]
7-
paths:
8-
- '.github/workflows/sync-repo-settings.yml'
9-
- '.github/settings.yml'
10-
# Only domain folders ending in dots.
11-
- '*.domain/*.yaml'
12-
- 'config.yaml'
7+
paths:
8+
- ".github/workflows/sync-repo-settings.yml"
9+
- ".github/settings.yml"
10+
# Only domain folders ending in dots.
11+
- "*.domain/*.yaml"
12+
- "config.yaml"
1313
schedule:
1414
# See: https://crontab.guru/#55_2_*_*_*
15-
- cron: '55 2 * * *'
15+
- cron: "55 2 * * *"
1616

1717
jobs:
1818
sync-repo-settings:
@@ -26,7 +26,7 @@ jobs:
2626
# See: https://github.com/apps/repo-settings-sync-g0v-network
2727
application_id: 194297
2828
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY_BASE64 }}
29-
29+
3030
- uses: actions/checkout@v2
3131

3232
- uses: exivity/actions/sync-defaults@main

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ setup: ## Prepare your local workspace
44
pipenv install
55

66
validate: ## Validate your configuration files
7-
@echo Note: This was not functional last time tested. Please ignore errors...
87
$(RUN) octodns-validate --config-file config.yaml
98
@echo Config files successfully validated!
109

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name = "pypi"
88
# Will need this untile octdns > 0.9.11 is released.
99
# See: https://github.com/g0v-network/domains/issues/20#issue-825088710
1010
octodns = "*"
11-
octodns-cloudflare = "*"
11+
octodns-cloudflare = ">=0.0.5"
1212

1313
[dev-packages]
1414

0 commit comments

Comments
 (0)