-
Notifications
You must be signed in to change notification settings - Fork 3
83 lines (71 loc) · 2.61 KB
/
domain-plan.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
on:
pull_request_target:
paths:
- '*.domain/*.yaml'
- '.github/config-plan-amendment.yml'
- '.github/workflows/domain-plan.yml'
defaults:
run:
shell: bash
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
jobs:
test-and-comment:
runs-on: ubuntu-20.04
steps:
- name: Checkout default branch
uses: actions/checkout@v2
- name: Checkout config files from PR
id: prhead
run: |
# Set $_sha to the first 7 char of PR head SHA
_sha="$(echo "${{ github.event.pull_request.head.sha }}" | cut -c 1-7)"
# Fetch PR head commit
git fetch origin refs/pull/${{ github.event.pull_request.number }}/head
# List changed config files in PR head
_files="$(git diff --name-only HEAD $_sha | grep "\.yaml$")"
# Checkout config files from PR head commit
if [ -n "$_files" ]; then git checkout "$_sha" -- $_files; fi
# Set output 'sha' to $_sha
echo "::set-output name=sha::${_sha}"
- name: Force HTML plan output
run: cat .github/config-plan-amendment.yml >> config.yaml
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install pipenv
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
- name: Install octoDNS
run: make setup
- name: Generate plan
run: make dry-run > octodns-sync.plan
- name: Get plan output
id: plan
run: |
# Parse plan output into $_plan
_plan="$(cat ${GITHUB_WORKSPACE}/octodns-sync.plan)"
_plan="${_plan//'%'/'%25'}"
_plan="${_plan//$'\n'/'%0A'}"
_plan="${_plan//$'\r'/'%0D'}"
# Set output 'plan' to $_plan
echo "::set-output name=plan::${_plan}"
- name: Find Comment
uses: peter-evans/find-comment@v1
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Automatically generated by octodns-sync
- name: Add or update PR comment
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: |
## OctoDNS Plan for `${{ steps.prhead.outputs.sha }}`
${{ steps.plan.outputs.plan }}
Automatically generated by octodns-sync
edit-mode: replace