Configure sync with upstream action #60
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: 'Upstream Sync' | |
permissions: | |
contents: write | |
actions: write | |
attestations: write | |
checks: write | |
deployments: write | |
discussions: write | |
issues: write | |
packages: write | |
pages: write | |
pull-requests: write | |
repository-projects: write | |
security-events: write | |
statuses: 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@v4 | |
with: | |
# optional: set the branch to checkout, | |
ref: upstream | |
token: ${{ github.token }} | |
# persist-credentials: false | |
- name: Sync upstream changes | |
id: sync | |
uses: aormsby/[email protected] | |
with: | |
target_sync_branch: upstream | |
target_repo_token: ${{ github.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: ${{ github.token }} | |
run: | | |
LAST_COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y-%m-%d %H:%M:%S' upstream) | |
gh pr create --title "Upstream sync. Last commit - $LAST_COMMIT_DATE" --body "This Pull Request was created automatically from workflow" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} |