Add Global Monitoring System by @johannawild #182
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |