This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | ||
# BASE=$(git merge-base HEAD upstream/master) | ||
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 }} |