forked from raycast/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (113 loc) · 5.09 KB
/
extensions_build_publish.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
106
107
108
109
110
111
112
113
114
115
116
117
name: Extensions
run-name: "${{ github.event_name == 'push' && format('Publish: {0}', github.event.head_commit.message) || (github.event_name == 'pull_request' && format('Check: {0}', github.event.pull_request.title) || github.event_name == 'workflow_dispatch' && format('Manual: {0} {1}', inputs.command, inputs.paths) || format('Event: {0}', github.event_name) ) }}"
on:
workflow_dispatch:
inputs:
paths:
description: 'Extensions to update (comma-separated relative paths for extensions) or ("extensions/**"" to execute on all possible subdirectories)'
required: true
command:
description: "Ray CLI command to run (build | publish)"
default: "build"
required: true
type: choice
options:
- build
- publish
cli_version:
description: 'CLI Version (optional, eg. "1.0.0")'
required: false
pull_request:
paths:
- "extensions/**"
branches: [main, master]
push:
paths:
- "extensions/**"
branches: [main, master]
jobs:
extensions_build_publish:
if: github.repository == 'raycast/extensions'
name: "${{ github.event_name == 'push' && 'Publish' || (github.event_name == 'pull_request' && 'Check' || github.event_name == 'workflow_dispatch' && inputs.command || github.event_name ) }}"
runs-on: macos-14
steps:
- name: Setup Xcode
uses: raycast/github-actions/[email protected]
- uses: actions/checkout@v4
with:
path: github_utils
sparse-checkout: |
.github
# This makes sure that the problems found while validating the extensions are shown in the PR diff
- name: Register Problem Matcher for Ray CLI
run: echo "##[add-matcher]github_utils/.github/ray.matcher.json"
- name: Generate 'allow_owners_only_for_extensions'
id: allow_owners_only_for_extensions
run: |
file_path="${{ github.workspace }}/github_utils/.github/public_raycast_extensions.txt"
if [[ -f "$file_path" ]]; then
echo "value<<EOF" >> "$GITHUB_OUTPUT"
while IFS= read -r line; do
echo "$line" >> "$GITHUB_OUTPUT"
done < "$file_path"
echo "EOF" >> "$GITHUB_OUTPUT"
fi
- name: Cleanup github_utils
run: |
rm -rf ${{ github.workspace }}/github_utils
- name: Run Ray CLI
id: ray_cli
uses: raycast/github-actions/[email protected]
with:
access_token: "${{ secrets.RAYCAST_CLI_ACCESS_TOKEN }}"
command: "${{ github.event.inputs.command }}"
paths: "${{ github.event.inputs.paths }}"
cli_version: "${{ github.event.inputs.cli_version }}"
allow_owners_only_for_extensions: "${{ steps.allow_owners_only_for_extensions.outputs.value }}"
- name: Post Store URLs
if: github.event_name == 'push'
uses: raycast/github-actions/[email protected]
with:
store_urls: ${{ steps.ray_cli.outputs.store_urls }}
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Reward Contributor
uses: actions/github-script@v7
if: github.event_name == 'push'
env:
PUBLISHING_BOT_TOKEN: ${{ secrets.RAYCAST_CLI_ACCESS_TOKEN }}
with:
github-token: ${{ secrets.RAYCAST_BOT_API_ACCESS_TOKEN }}
script: |
const result = await github.rest.repos.getContent({
mediaType: {
format: "raw",
},
owner: context.repo.owner,
repo: context.repo.repo,
path: "scripts/reward.js",
});
require('fs').writeFileSync('./reward.js', result.data);
const script = require('./reward')
await script({
github,
context,
fetch,
})
- name: Notify Failure to Slack
if: failure() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: raycast/github-actions/slack-send@master
with:
webhook: ${{ github.event_name == 'workflow_dispatch' && secrets.SLACK_RELEASE_CHANNEL_WEBHOOK_URL || secrets.SLACK_STREAM_ERRORS_STORE_PUBLIC }}
color: "danger"
text: |
:no_entry_sign: ${env.GITHUB_WORKFLOW} has failed
<${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}|Action logs> | <${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/commit/${ env.GITHUB_SHA }|Commit: ${ env.GITHUB_SHA.substr(0,8) }>
- name: Notify Success to Slack
if: success() && github.event_name == 'workflow_dispatch'
uses: raycast/github-actions/slack-send@master
with:
webhook: ${{ secrets.SLACK_RELEASE_CHANNEL_WEBHOOK_URL }}
color: "good"
text: |
:white_check_mark: ${env.GITHUB_WORKFLOW} has succeeded
<${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}|Action logs> | <${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/commit/${ env.GITHUB_SHA }|Commit: ${ env.GITHUB_SHA.substr(0,8) }>