Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Test example for solvaholic/octodns-sync#41
Browse files Browse the repository at this point in the history
  • Loading branch information
solvaholic authored Feb 16, 2021
1 parent 4f21c1c commit 0503bfa
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions .github/workflows/octodns-sync.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
name: Run octodns-sync to test config

# Use this workflow to:
# - Manually test octodns config
# - Automatically test octodns config

on:
# Run when manually triggered
workflow_dispatch:

# Run on pull request open, reopen, and synchronize
pull_request:
branches: [main]

pull_request_target:
jobs:
test:
runs-on: ubuntu-latest
test-and-comment:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout main
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
# Checkout *.yaml from PR head commit
git checkout "$_sha" -- *.yaml
# Set output 'sha' to $_sha
echo "::set-output name=sha::${_sha}"
- name: Test changes to DNS config
id: octodns-sync
uses: solvaholic/octodns-sync@issue40
uses: solvaholic/octodns-sync@main
with:
config_path: test-config.yaml
- name: A piece of duct tape
id: meta
- 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}"
_sha="$(echo "${{ github.event.pull_request.head.sha }}" | cut -c 1-7)"
echo "::set-output name=sha::${_sha}"
- name: Find Comment
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: peter-evans/find-comment@v1
id: fc
with:
Expand All @@ -49,9 +46,9 @@ jobs:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
## OctoDNS Plan for `${{ steps.meta.outputs.sha }}`
## OctoDNS Plan for `${{ steps.prhead.outputs.sha }}`
${{ steps.meta.outputs.plan }}
${{ steps.plan.outputs.plan }}
Automatically generated by octodns-sync
edit-mode: replace

0 comments on commit 0503bfa

Please sign in to comment.