-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (69 loc) · 2.54 KB
/
update-directory.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
name: Update directory
on:
schedule:
- cron: '0 10-15 * * *'
workflow_dispatch:
jobs:
update-directory:
runs-on: ubuntu-latest
steps:
- name: check out
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: setup node
uses: actions/setup-node@v4.0.2
with:
node-version: latest
cache: 'npm'
- name: npm install
run: |
npm install
- name: update directory
run: |
echo "UPDATED_PLUGIN_DATA=$(npm run --silent plugins-directory update-directory)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: set update name
if: ${{ env.UPDATED_PLUGIN_DATA }}
run: |
echo "UPDATED_PLUGIN=$(npm run --silent plugins-directory update-name-from-plugin-data)" >> $GITHUB_ENV
- name: save
if: ${{ env.UPDATED_PLUGIN }}
run: |
# Git config
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git checkout -b "update-directory/$UPDATED_PLUGIN"
git add .
git commit --allow-empty -m "$UPDATED_PLUGIN"
git push --set-upstream origin "update-directory/$UPDATED_PLUGIN"
- name: Open pull request
if: ${{ env.UPDATED_PLUGIN }}
uses: actions/github-script@v7
with:
script: |
const { repo, owner } = context.repo;
const updatedPluginData = JSON.parse(Buffer.from(process.env.UPDATED_PLUGIN_DATA, 'base64').toString());
const name = '## ' + '`` ' + (updatedPluginData.packageName ?? '-') + ' ``\n';
const description = '### description:\n- ' + '`` ' + (updatedPluginData.description ?? '-') + ' ``\n';
const keywords = '### keywords:\n- ' + (updatedPluginData.keywords ?? []).map(x => '`` ' + x + ' ``').join('\n- ') + '\n';
const result = await github.rest.pulls.create({
title: updatedPluginData.updateName,
owner,
repo,
head: `update-directory/${updatedPluginData.updateName}`,
base: 'main',
body: [
'_This PR is auto-generated_',
name,
description,
keywords,
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['update directory']
});