-
Notifications
You must be signed in to change notification settings - Fork 48
82 lines (74 loc) · 2.76 KB
/
metadata.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
79
80
81
82
name: Fetch Addon Metadata
on:
pull_request_review:
types: [submitted]
workflow_dispatch:
inputs:
base_ref:
description: "Base branch reference (e.g., main)"
required: true
head_ref:
description: "Head branch reference (e.g., feature-branch)"
required: true
jobs:
metadata:
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
name: Checkout LLS-Addons
with:
submodules: false
fetch-depth: 0
- name: Set Base and Head Refs
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
BASE_REF="${{ github.event.inputs.base_ref }}"
HEAD_REF="${{ github.event.inputs.head_ref }}"
else
BASE_REF="${{ github.event.pull_request.base.sha }}"
HEAD_REF="${{ github.event.pull_request.head.sha }}"
fi
echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
- name: Fetch Base Branch
run: |
# Fetch all history for the base branch and PR head
git fetch origin ${BASE_REF}
git fetch origin ${HEAD_REF}
- name: Detect Added Submodules
run: |
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..${HEAD_REF} | grep '^Submodule' | awk '{ print $2 }')
echo "Added submodules: $ADDED_SUBMODULES"
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
- name: Fetch submodules
run: |
for submodule in $ADDED_SUBMODULES; do
echo "Getting submodule: $submodule"
git submodule update --init --recursive $submodule
done
# Custom action that gets metadata on each addon
- uses: dsaltares/[email protected]
name: Get submodule metadata fetching action
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: LuaLS/LLS-Addons-Action
file: dist.zip
target: action.zip
- name: Unzip custom action
run: unzip action.zip -d action
- uses: ./action/dist
name: Get Addon Metadata
# Commit new metadata
- name: Commit Metadata
uses: stefanzweifel/[email protected]
with:
commit_message: "chore: Update Addon Metadata"
file_pattern: addons/*/info.json
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com