Skip to content

Configure sync with upstream action #30

Configure sync with upstream action

Configure sync with upstream action #30

Workflow file for this run

name: 'Upstream Sync'
permissions:
contents: write
on:
pull_request:
schedule:
- cron: '0 7 * * 1'
# scheduled at 07:00 every Monday
workflow_dispatch: # click the button on Github repo!
inputs:
sync_test_mode: # Adds a boolean option that appears during manual workflow run for easy test mode config
description: 'Fork Sync Test Mode'
type: boolean
default: false
jobs:
sync_latest_from_upstream:
runs-on: ubuntu-latest
name: Sync latest commits from upstream repo
steps:
- name: Checkout target repo
uses: actions/checkout@v3
with:
# optional: set the branch to checkout,
ref: upstream
token: ${{ secrets.ACCESS_TOKEN }}
# persist-credentials: false
- name: Sync upstream changes
id: sync
uses: aormsby/[email protected]
with:
target_sync_branch: upstream
target_repo_token: ${{ secrets.ACCESS_TOKEN }}
upstream_sync_branch: master
upstream_sync_repo: polkadot-js/apps
# Set test_mode true during manual dispatch to run tests instead of the true action!!
test_mode: ${{ inputs.sync_test_mode }}
# Display a sample message based on the sync output var 'has_new_commits'
- name: New commits found
id: last_commit
if: steps.sync.outputs.has_new_commits == 'true'
run: |
echo "New commits were found to sync."
- name: No new commits
if: steps.sync.outputs.has_new_commits == 'false'
run: echo "There were no new commits."
- name: Show value of 'has_new_commits'
run: echo ${{ steps.sync.outputs.has_new_commits }}
- name: Create Pull Request
if: steps.sync.outputs.has_new_commits == 'true'
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
LAST_COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y-%m-%d %H:%M:%S' upstream)
gh pr create --title "Test PR. Last commit - $LAST_COMMIT_DATE" --body "This PR auto created" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }}