-
Notifications
You must be signed in to change notification settings - Fork 24
66 lines (57 loc) · 2.04 KB
/
add-category.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
name: Add Category
run-name: Add Category ${{ inputs.categoryName }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
categoryName:
description: 'Category Name'
type: string
required: true
categoryPath:
description: 'Path: category/sub-category'
type: string
required: true
jobs:
add-category:
runs-on: ubuntu-latest
env:
CATEGORY_NAME: ${{ inputs.categoryName }}
CATEGORY_PATH: ${{ inputs.categoryPath }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Install dependencies
run: npm install
- name: Run script
id: node
run: |
node src/add-cat.mjs "$CATEGORY_NAME" "$CATEGORY_PATH"
npm run build
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit changes ${{ steps.node.outputs.changes }}
if: ${{ steps.node.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 Category: $CATEGORY_NAME"
- name: Push changes
if: ${{ steps.node.outputs.changes == 'true' }}
uses: ad-m/github-push-action@master
with:
branch: add-category-${{ github.run_number }}
force: true
- name: Create Pull Request
if: ${{ steps.node.outputs.changes == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: add-category-${{ github.run_number }}
commit-message: Add category ${{ inputs.categoryName }}
title: Add category ${{ inputs.categoryName }}
body: Created via workflow. In case of merge conflicts, re-run all jobs on [Run ${{ github.run_number }}](https://github.com/bellingcat/toolkit/actions/runs/${{ github.run_id }}).