Skip to content

Regenerate haskell-ci workflows #81

Regenerate haskell-ci workflows

Regenerate haskell-ci workflows #81

Workflow file for this run

name: 'Regenerate haskell-ci workflows'
on:
workflow_dispatch:
schedule:
# Run every Saturday
- cron: '0 3 * * 6'
jobs:
refresh:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo:
- X11
- X11-xft
- xmonad
- xmonad-contrib
steps:
- name: Clone xmonad-maintenance
uses: actions/checkout@v4
with:
path: maint
- name: Clone project
uses: actions/checkout@v4
with:
repository: xmonad/${{ matrix.repo }}
path: project
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- name: Clone haskell-ci
uses: actions/checkout@v4
with:
repository: haskell-CI/haskell-ci
path: haskell-ci
- name: Get haskell-ci version
id: haskell-ci-version
working-directory: haskell-ci
run: |
{ echo -n version=; git rev-parse HEAD; } >> $GITHUB_OUTPUT
- name: Setup Haskell
id: setup
uses: haskell-actions/setup@v2
with:
ghc-version: 9.4
- name: Restore cached cabal store
id: cache-cabal
uses: actions/cache/restore@v4
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: cabal-store-${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}-haskell-ci-${{ steps.haskell-ci-version.outputs.version }}
restore-keys: |
cabal-store-${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}-
- name: Install haskell-ci
working-directory: haskell-ci
run: |
cabal install
- name: Cache cabal store
uses: actions/cache/save@v4
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache-cabal.outputs.cache-primary-key }}
- name: Set up git user name/email
run: |
set -ex
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Prepare git stuff
working-directory: project
run: |
set -ex
git remote set-head --auto origin
git checkout -b haskell-ci-update
- name: Update tested-with
working-directory: project
run: |
set -ex
../maint/update-tested-with.sh
# commit if anything changed
git diff --quiet --exit-code || git commit -a -m 'ci: Bump GHC patch versions in tested-with'
- name: Regenerate haskell-ci
working-directory: project
run: |
set -ex
../maint/patch-haskell-ci-hackage.sh
../maint/haskell-ci-regenerate.sh
# commit if anything changed
git diff --quiet --exit-code || git commit -a -m 'ci: Regenerate haskell-ci'
- name: Create pull request if anything changed
working-directory: project
run: |
set -ex
# exit if there were no changes or if only YAML comments changed
git diff --quiet --exit-code --ignore-matching-lines='^#' origin/HEAD && exit
# exit if there's already a haskell-ci-update branch with the same contents
if git fetch origin haskell-ci-update; then
git diff --quiet --exit-code FETCH_HEAD && exit
fi
git push -f -u origin haskell-ci-update:haskell-ci-update
# open pull request if there isn't one already
err=$(
GITHUB_TOKEN="${ADMIN_GITHUB_TOKEN:?}" gh pr create \
--title='ci: Regenerate haskell-ci' \
--body='(automatic PR by https://github.com/liskin/xmonad-maintenance)' \
2>&1
) && ret=$? || ret=$?
if (( ret )) && [[ "$err" != *"a pull request for branch"*"already exists:"* ]]; then
exit $?
else
printf '%s\n' "$err" >> $GITHUB_STEP_SUMMARY
fi
env:
ADMIN_GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- name: Export changes bundle
if: |
!cancelled()
working-directory: project
run: |
git diff --quiet --exit-code origin/HEAD || git bundle create changes.bundle origin/HEAD..
- name: Publish changes bundle as artifact
if: |
!cancelled()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.repo }}
path: project/changes.bundle
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1