-
Notifications
You must be signed in to change notification settings - Fork 2
70 lines (63 loc) · 2.13 KB
/
pr-validation.yml
File metadata and controls
70 lines (63 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: PR Validation
on:
pull_request:
paths:
- "Casks/**"
- ".github/workflows/pr-validation.yml"
permissions: {}
jobs:
detect-changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
casks: ${{ steps.changed.outputs.casks }}
has_cask_changes: ${{ steps.changed.outputs.has_cask_changes }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Get changes
id: changed
run: |
# Detect changed casks
CASKS=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- 'Casks/*.rb' | xargs -I{} basename {} .rb)
if [ -z "$CASKS" ]; then
echo "No cask changes detected"
echo "has_cask_changes=false" >> $GITHUB_OUTPUT
echo "casks=[]" >> $GITHUB_OUTPUT
else
JSON_ARRAY=$(echo "$CASKS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "Changed casks: $JSON_ARRAY"
echo "has_cask_changes=true" >> $GITHUB_OUTPUT
echo "casks=$JSON_ARRAY" >> $GITHUB_OUTPUT
fi
validate-cask:
name: Validate Cask (${{ matrix.cask }})
runs-on: macos-26
needs: detect-changes
if: needs.detect-changes.outputs.has_cask_changes == 'true'
permissions:
contents: read
strategy:
fail-fast: false
matrix:
cask: ${{ fromJson(needs.detect-changes.outputs.casks) }}
env:
TAP_PATH: ${{ github.repository_owner }}/homebrew-tap
CASK_PATH: ${{ github.repository_owner }}/homebrew-tap/${{ matrix.cask }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Tap this repository
run: |
ABS_TAP_PATH="$(brew --repository)/Library/Taps/${TAP_PATH}"
mkdir -p "$ABS_TAP_PATH"
cp -r . "$ABS_TAP_PATH"
- name: Validate cask
uses: ./validate-cask
with:
cask-path: ${{ env.CASK_PATH }}
tap-path: ${{ env.TAP_PATH }}