-
Notifications
You must be signed in to change notification settings - Fork 15
75 lines (64 loc) · 2.24 KB
/
add-tool.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
name: Add Tool
run-name: Add ${{ inputs.toolName }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
toolName:
description: 'Tool Name'
type: string
required: true
email:
description: 'Team Member Email (optional)'
type: string
jobs:
add-tool:
runs-on: ubuntu-latest
env:
TOOL_NAME: ${{ inputs.toolName }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Mask secrets
run: |
INPUT_EMAIL==$(jq -r '.inputs.email' $GITHUB_EVENT_PATH)
echo ::add-mask::$INPUT_EMAIL
echo EMAIL=$INPUT_EMAIL >> $GITHUB_ENV
- name: Create Gitbook Space and Team (look here for the link!)
id: add-space
env:
GITBOOK_API_TOKEN: ${{ secrets.GITBOOK_API_TOKEN }}
run: |
node src/add-space.mjs "$TOOL_NAME" "$EMAIL"
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit changes ${{ steps.add-space.outputs.changes }}
if: ${{ steps.add-space.outputs.changes == 'true' }}
run: |
git status --porcelain
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Add Space $TOOL_NAME"
- name: Create new tool folder (look here for git sync config!)
id: add-folder
run: |
node src/add-tool.mjs "$TOOL_NAME"
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit changes ${{ steps.add-folder.outputs.changes }}
if: ${{ steps.add-folder.outputs.changes == 'true' }}
run: |
git status --porcelain
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Add Tool $TOOL_NAME"
- name: Push changes
if: ${{ steps.add-folder.outputs.changes == 'true' || steps.add-space.outputs.changes == 'true' }}
uses: ad-m/github-push-action@master
with:
branch: main