Sync with Upstream #2027
This file contains hidden or 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 with Upstream | |
| on: | |
| schedule: | |
| # Run every 3 hours | |
| - cron: '0 */3 * * *' | |
| # Allow manual triggering of the workflow | |
| workflow_dispatch: | |
| permissions: | |
| # Allow the workflow to push changes to the repository | |
| contents: write | |
| jobs: | |
| sync: | |
| name: Sync with upstream | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Since the default branch has changed, we have to manually configure this. | |
| ref: master | |
| - name: Set up Git Credentials | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Configure upstream branch | |
| run: | | |
| upstream_exists=$(git remote | grep upstream || echo "") | |
| if [ -z "$upstream_exists" ]; then | |
| echo "::group::Adding upstream" | |
| git remote add upstream https://github.com/microsoft/winget-pkgs.git | |
| echo "::endgroup::" | |
| fi | |
| echo "::group::Fetching upstream" | |
| git fetch --progress --verbose --prune upstream master | |
| echo "::endgroup::" | |
| - name: Rebase with upstream | |
| run: | | |
| git switch master | |
| git reset --hard origin/master | |
| git rebase upstream/master | |
| - name: Push changes | |
| run: | | |
| git push --progress --force-with-lease origin |