-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (85 loc) · 2.72 KB
/
homebrew-tap-info.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Homebrew TAP INFO (Workflow)
on:
workflow_call:
inputs:
forced:
description: "Force execution - Default: false"
required: false
type: boolean
default: false
github_actions_artifact_name:
description: "Artifact name for tap information - Default: homebrew-tap-info-json"
required: false
type: string
default: "homebrew-tap-info-json"
jobs:
check_artifact_ref:
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.get-ref.outputs.ref }}
if: ${{ ! inputs.forced }}
steps:
- id: download-artifacts
uses: actions/download-artifact@v4
with:
name: ${{ inputs.github_actions_artifact_name }}
path: ${{ inputs.github_actions_artifact_name }}
- id: get-ref
run: |
echo ref=$(jq -r '.[0]."HEAD"' ${{ inputs.github_actions_artifact_name }}) >> $GITHUB_OUTPUT
check_git_ref:
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.get-ref.outputs.ref }}
if: ${{ ! inputs.forced }}
steps:
- id: get-ref
run: |
echo ref=${{ github.head_ref }} >> $GITHUB_OUTPUT
check_freshness:
runs-on: ubuntu-latest
needs: [ check_artifact_ref, check_git_ref ]
outputs:
go-ahead: ${{ steps.check.outputs.yesno }}
if: ${{ ! inputs.forced }}
steps:
- id: check
run: |
if [[ ${{ inputs.forced }} ]]; then
echo yesno=1 >> $GITHUB_OUTPUT
elif [[ ${{ needs.check_artifact_ref.outputs.ref }} != ${{ needs.check_git_ref.outputs.ref }} ]]; then
echo yesno=1 >> $GITHUB_OUTPUT
else
echo yesno=0 >> $GITHUB_OUTPUT
fi
homebrew_tap_info:
runs-on: ubuntu-latest # macOS-latest?
needs: check_freshness
env:
HOMEBREW_NO_ANALYTICS: 1
outputs:
homebrew-tap-info-json: ${{ steps.echo.outputs.json }}
if: ${{ inputs.forced || needs.check_freshness.outputs.go-ahead }}
steps:
- id: setup-homebrew
uses: sazriel26/github-actions-sandbox/setup-homebrew-on-github-actions@main
with:
developer-mode: true
- id: homebrew-tap
run: |
brew tap ${{ github.repository }}
- id: homebrew-tap-info
run: |
brew tap-info --json ${{ github.repository }} \
> ${{ inputs.github_actions_artifact_name }}
- id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.github_actions_artifact_name }}
path: ${{ inputs.github_actions_artifact_name }}
overwrite: true
- id: echo
run: |
json=$(< ${{ inputs.github_actions_artifact_name }})
echo json=${json} >> $GITHUB_OUTPUT
# EoF