Skip to content

Synchronization Upstream #820

Synchronization Upstream

Synchronization Upstream #820

name: Synchronization Upstream
on:
schedule:
- cron: "0 1 * * *" # every day at 1:00
workflow_dispatch:
env:
UPSTREAM: "https://github.com/aleksandr-m/gitflow-maven-plugin"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPSTREAM_BRANCH_NAME: master
BRANCH_NAME: auto-upstream-merge
ORIGIN_PATH: thundra-io-demo/gitflow-maven-plugin
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GITHUB_USERNAME: thundra-io-demo
jobs:
merge_upstream:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
lfs: true
fetch-depth: 0
- name: Sync and merge upstream repository with your current repository
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git remote add upstream ${{ env.UPSTREAM }}
git fetch upstream ${{ env.UPSTREAM_BRANCH_NAME }}:${{ env.BRANCH_NAME }}
git checkout ${{ env.BRANCH_NAME }}
git rm -f .github/workflows/*
git rm -f README.md
git remote set-url origin "https://x-access-token:${{ env.GITHUB_TOKEN }}@github.com/${{ env.ORIGIN_PATH }}"
git commit -am "Merge upstream" || true
git push -f -u origin ${{ env.BRANCH_NAME }}
- name: Install hub
uses: geertvdc/setup-hub@master
- name: Automatically create pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ secrets.GITHUB_USER }}
run: |
hub pull-request -m "Merge upstream" -b ${{ env.GITHUB_USERNAME}}:${{ env.UPSTREAM_BRANCH_NAME }} -h ${{ env.GITHUB_USERNAME }}:${{ env.BRANCH_NAME }} --no-edit || true