-
Notifications
You must be signed in to change notification settings - Fork 11
59 lines (50 loc) · 1.68 KB
/
change_module_state.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
name: Enable/Disable Module
on:
workflow_dispatch:
inputs:
module_id:
description: 'Module ID'
required: true
reason:
description: 'Reason for disabling'
default: 'Reason was not specified.'
required: false
state:
type: boolean
description: 'Enable/Disable'
required: true
default: true
env:
TRACK_FILE_JSON: modules/${{ inputs.module_id }}/track.json
TRACK_FILE_YAML: modules/${{ inputs.module_id }}/track.yaml
STATE: ${{ inputs.state }}
jobs:
change_state:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Modify JSON file
run: |
if [ -f "$TRACK_FILE_JSON" ]; then
jq '.enable = ${{ inputs.state }}' "$TRACK_FILE_JSON" > tmp.json && mv tmp.json "$TRACK_FILE_JSON"
fi
- name: Modify YAML file
run: |
if [ -f "$TRACK_FILE_YAML" ]; then
yq e '.enable = ${{ inputs.state }}' -i "$TRACK_FILE_YAML"
fi
- name: Configure Git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Commit and push changes
run: |
[ -f "$TRACK_FILE_JSON" ] && git add "$TRACK_FILE_JSON" || true
[ -f "$TRACK_FILE_YAML" ] && git add "$TRACK_FILE_YAML" || true
if [ "$STATE" = "true" ]; then
git commit -m "Enable ${{ inputs.module_id }}" || true
else
git commit -m "Disable ${{ inputs.module_id }}" -m "${{ inputs.reason }}" || true
fi
git push