Skip to content

Add workflow to check for new tagged version in miekg/dns and create PR into zmap/dns #10

Add workflow to check for new tagged version in miekg/dns and create PR into zmap/dns

Add workflow to check for new tagged version in miekg/dns and create PR into zmap/dns #10

name: Sync miekg/dns with zmap/dns
on:
# Only for testing
pull_request:
# branches: [github-action-when-upstream-tagged]
schedule:
- cron: '0 0 * * *' # This will run the action daily
workflow_dispatch: # Allows manual trigger
jobs:
sync-fork:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Git user name and email
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Fetch upstream changes
run: |
git remote add upstream https://github.com/miekg/dns.git
git fetch upstream
- name: Check for changes
id: check-changes
run: |
if [ $(git rev-list --count HEAD..upstream/master) -gt 0 ]; then
echo "::set-output name=changes::true"
else
echo "::set-output name=changes::false"
fi
- name: Create pull request
if: steps.check-changes.outputs.changes == 'true'
run: |
git checkout -b sync-$(date +'%Y-%m-%d')
git merge upstream/master --no-edit
git push origin sync-$(date +'%Y-%m-%d')
gh pr create --title "Sync with upstream" --body "Automated PR to sync with upstream." --base master --head sync-$(date +'%Y-%m-%d\nDon't forget to tag the new version so it is picked up by users')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}