Skip to content

Commit 2ced5fd

Browse files
authored
Merge pull request #31 from ulysses4ever/update-ci-automation
Update-CI automation
2 parents 7eb342f + 43acc15 commit 2ced5fd

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Update Haskell CI when PR updates .cabal file and its title starts with "tested-with"
2+
3+
on:
4+
pull_request:
5+
# Fire for typical PR lifecycle events
6+
types: [opened, reopened]
7+
# Only run when the specified file(s) are part of the PR diff.
8+
# CHANGE THIS to the path(s) you care about (supports globs).
9+
paths:
10+
- '**/*.cabal'
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
update-ci:
22+
# Require: title starts with "tested-with" (case-insensitive)
23+
# and PR originates from the same repository (safe to push back)
24+
if: >
25+
startsWith(toLower(github.event.pull_request.title), 'tested-with') &&
26+
github.event.pull_request.head.repo.full_name == github.repository
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Check out PR branch
31+
uses: actions/checkout@v4
32+
with:
33+
# Checkout the PR head branch so we can commit back to it
34+
ref: ${{ github.head_ref }}
35+
36+
# Haskell-specific: install haskell-ci from source and regenerate workflows
37+
- name: Set up Haskell toolchain
38+
uses: haskell/actions/setup@v2
39+
with:
40+
ghc-version: "latest"
41+
cabal-version: "latest"
42+
43+
- name: Install haskell-ci
44+
run: |
45+
set -euxo pipefail
46+
git clone --depth 1 https://github.com/haskell-CI/haskell-ci.git .tooling/haskell-ci
47+
cd .tooling/haskell-ci
48+
cabal update
49+
cabal build exe:haskell-ci
50+
cabal install exe:haskell-ci --overwrite-policy=always --installdir="$HOME/.local/bin" --install-method=copy
51+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
52+
53+
- name: Regenerate workflows with haskell-ci
54+
run: |
55+
set -euxo pipefail
56+
# If your repo uses a .haskell-ci file, regenerate from it:
57+
if [ -f .haskell-ci ]; then
58+
haskell-ci regenerate
59+
else
60+
# Fallback: generate from cabal metadata (adjust command as needed)
61+
haskell-ci generate
62+
fi
63+
64+
- name: Commit changes back to PR branch
65+
uses: stefanzweifel/git-auto-commit-action@v5
66+
with:
67+
commit_message: "chore(ci): regenerate CI from tested-with PR"
68+
branch: ${{ github.head_ref }}
69+
# Limit to the typical files haskell-ci may edit
70+
file_pattern: |
71+
.github/workflows/**
72+
.haskell-ci

0 commit comments

Comments
 (0)