Skip to content

Commit 2389dbc

Browse files
committed
ci: split actions
1 parent 5ef15d5 commit 2389dbc

File tree

2 files changed

+62
-56
lines changed

2 files changed

+62
-56
lines changed

.github/workflows/metadata.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Fetch Addon Metadata
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
metadata:
9+
if: ${{ github.event.review.state == 'approved' }}
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v3
15+
name: Checkout LLS-Addons
16+
with:
17+
submodules: false
18+
19+
- name: Fetch Base Branch
20+
run: |
21+
# Fetch all history for the base branch and PR head
22+
git fetch origin ${{ github.base_ref }} --depth=1
23+
git fetch origin ${{ github.head_ref }} --depth=1
24+
25+
- name: Detect Added Submodules
26+
run: |
27+
BASE_REF=${{ github.event.pull_request.base.sha }}
28+
HEAD_REF=${{ github.event.pull_request.head.sha }}
29+
30+
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..${HEAD_REF} | grep '^Submodule' | awk '{ print $2 }')
31+
echo "Added submodules: $ADDED_SUBMODULES"
32+
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
33+
34+
- name: Fetch submodules
35+
run: |
36+
for submodule in $ADDED_SUBMODULES; do
37+
echo "Getting submodule: $submodule"
38+
git submodule update --init --recursive $submodule
39+
done
40+
41+
# Custom action that gets metadata on each addon
42+
- uses: dsaltares/fetch-gh-release-asset@1.1.0
43+
name: Get submodule metadata fetching action
44+
with:
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
repo: LuaLS/LLS-Addons-Action
47+
file: dist.zip
48+
target: action.zip
49+
- name: Unzip custom action
50+
run: unzip action.zip -d action
51+
- uses: ./action/dist
52+
name: Get Addon Metadata
53+
54+
# Commit new metadata
55+
- name: Commit Metadata
56+
uses: stefanzweifel/git-auto-commit-action@v4.16.0
57+
with:
58+
commit_message: "chore: Update Addon Metadata"
59+
file_pattern: addons/*/info.json
60+
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
61+
commit_user_name: github-actions[bot]
62+
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com

.github/workflows/pull_request.yml

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -43,59 +43,3 @@ jobs:
4343
token: ${{ secrets.GITHUB_TOKEN }}
4444
version: latest
4545
args: --check addons
46-
47-
metadata:
48-
name: "Fetch Addon Metadata"
49-
runs-on: ubuntu-latest
50-
permissions:
51-
contents: write
52-
steps:
53-
- uses: actions/checkout@v3
54-
name: Checkout LLS-Addons
55-
with:
56-
submodules: false
57-
58-
- name: Fetch Base Branch
59-
run: |
60-
# Fetch all history for the base branch and PR head
61-
git fetch origin ${{ github.base_ref }} --depth=1
62-
git fetch origin ${{ github.head_ref }} --depth=1
63-
64-
- name: Detect Added Submodules
65-
run: |
66-
BASE_REF=${{ github.event.pull_request.base.sha }}
67-
HEAD_REF=${{ github.event.pull_request.head.sha }}
68-
69-
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..${HEAD_REF} | grep '^Submodule' | awk '{ print $2 }')
70-
echo "Added submodules: $ADDED_SUBMODULES"
71-
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
72-
73-
- name: Fetch submodules
74-
run: |
75-
for submodule in $ADDED_SUBMODULES; do
76-
echo "Getting submodule: $submodule"
77-
git submodule update --init --recursive $submodule
78-
done
79-
80-
# Custom action that gets metadata on each addon
81-
- uses: dsaltares/fetch-gh-release-asset@1.1.0
82-
name: Get submodule metadata fetching action
83-
with:
84-
token: ${{ secrets.GITHUB_TOKEN }}
85-
repo: LuaLS/LLS-Addons-Action
86-
file: dist.zip
87-
target: action.zip
88-
- name: Unzip custom action
89-
run: unzip action.zip -d action
90-
- uses: ./action/dist
91-
name: Get Addon Metadata
92-
93-
# Commit new metadata
94-
- name: Commit Metadata
95-
uses: stefanzweifel/git-auto-commit-action@v4.16.0
96-
with:
97-
commit_message: "chore: Update Addon Metadata"
98-
file_pattern: addons/*/info.json
99-
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
100-
commit_user_name: github-actions[bot]
101-
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com

0 commit comments

Comments
 (0)