Auto Rebase #6
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: "Auto Rebase" | |
| on: | |
| schedule: | |
| # Run daily at 00:00 UTC | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| rebase: | |
| name: "Rebase from upstream FFmpeg" | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| branch: [master, workflows] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Add upstream remote | |
| run: git remote add upstream https://github.com/FFmpeg/FFmpeg.git | |
| - name: Fetch upstream master | |
| run: git fetch upstream master | |
| - name: Rebase on upstream master | |
| run: | | |
| set -euxo pipefail | |
| echo "Current branch: ${{ matrix.branch }}" | |
| echo "Current HEAD: $(git log --oneline -1)" | |
| git rebase upstream/master | |
| echo "New HEAD: $(git log --oneline -1)" | |
| - name: Push changes | |
| run: git push origin ${{ matrix.branch }} --force-with-lease | |
| - name: Trigger test workflow | |
| if: matrix.branch == 'workflows' | |
| run: | | |
| WORKFLOW_ID=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows" \ | |
| -q '.workflows[] | select(.path==".github/workflows/test.yml") | .id') | |
| if [ -n "$WORKFLOW_ID" ]; then | |
| gh api -X POST "repos/${GITHUB_REPOSITORY}/actions/workflows/${WORKFLOW_ID}/dispatches" \ | |
| -f ref=workflows | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |