|
| 1 | +name: Rebase against upstream |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + issues: write |
| 11 | + pull-requests: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + rebase: |
| 15 | + name: Rebase now! |
| 16 | + runs-on: ubuntu-latest |
| 17 | + env: |
| 18 | + UPSTREAM_REPO: https://github.com/haskell/cabal.git |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + persist-credentials: false |
| 25 | + |
| 26 | + - run: | |
| 27 | + set -eux |
| 28 | +
|
| 29 | + gh repo set-default stable-haskell/cabal |
| 30 | + git config checkout.defaultRemote origin |
| 31 | +
|
| 32 | + # required to apply patches |
| 33 | + git config user.email "[email protected]" |
| 34 | + git config user.name "GitHub CI" |
| 35 | +
|
| 36 | + # this does not push |
| 37 | + branches=$(bash .github/scripts/rebase.sh ${{ env.UPSTREAM_REPO }}) |
| 38 | +
|
| 39 | + # now push |
| 40 | + git checkout ${{ github.ref_name }} |
| 41 | + bash .github/scripts/push.sh ${{ env.UPSTREAM_REPO }} https://${{ secrets.REBASE_PAT }}@github.com/${{ github.repository }}.git "${branches}" |
| 42 | + shell: bash |
| 43 | + env: |
| 44 | + GH_TOKEN: ${{ github.token }} |
| 45 | +
|
| 46 | +
|
| 47 | + # create an issue with a link to the workflow run on failure |
| 48 | + - if: failure() |
| 49 | + run: | |
| 50 | + set -eux |
| 51 | + gh repo set-default stable-haskell/cabal |
| 52 | + for issue in $(gh issue list --label rebase-failure --json url -q '.[] | .url') ; do |
| 53 | + gh issue close "${issue}" |
| 54 | + done |
| 55 | + gh issue create --title "Rebase failed on $(date -u +"%Y-%m-%d")" --label rebase-failure --body "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 56 | + env: |
| 57 | + GH_TOKEN: ${{ github.token }} |
| 58 | + |
| 59 | + # we always want the original repo and the patches that were applied |
| 60 | + # for debugging and backup reasons |
| 61 | + - if: always() |
| 62 | + run: | |
| 63 | + git checkout -f master || true |
| 64 | + git archive master > backup.tar |
| 65 | + tar -rf backup.tar .git rebase |
| 66 | + - if: always() |
| 67 | + name: Upload backup |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + if-no-files-found: error |
| 71 | + retention-days: 7 |
| 72 | + name: backup |
| 73 | + path: | |
| 74 | + ./backup.tar |
0 commit comments