11on :
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
89defaults :
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
0 commit comments