Skip to content

Commit 1a42420

Browse files
committed
refactor: github action
1 parent 05b3eaf commit 1a42420

File tree

2 files changed

+95
-82
lines changed

2 files changed

+95
-82
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/pull_request.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Check Added Submodules
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
style:
10+
name: Run StyLua
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
name: Checkout LLS-Addons
15+
with:
16+
submodules: false
17+
18+
- name: Fetch Base Branch
19+
run: |
20+
git fetch origin ${GITHUB_BASE_REF}
21+
git checkout ${GITHUB_BASE_REF}
22+
23+
- name: Detect Added Submodules
24+
run: |
25+
BASE_REF=${{github.event.pull_request.base.sha}}
26+
git checkout $BASE_REF
27+
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..HEAD | grep '^Submodule' | awk '{ print $2 }')
28+
echo "Added submodules: $ADDED_SUBMODULES"
29+
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
30+
31+
- name: Fetch submodules
32+
run: |
33+
for submodule in $ADDED_SUBMODULES; do
34+
echo "Getting submodule: $submodule"
35+
git submodule update --init --recursive $submodule
36+
done
37+
38+
- uses: JohnnyMorganz/[email protected]
39+
name: Run StyLua
40+
with:
41+
token: ${{ secrets.GITHUB_TOKEN }}
42+
version: latest
43+
args: --check addons
44+
45+
metadata:
46+
name: "Fetch Addon Metadata"
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v3
50+
name: Checkout LLS-Addons
51+
with:
52+
submodules: false
53+
54+
- name: Fetch Base Branch
55+
run: |
56+
git fetch origin ${GITHUB_BASE_REF}
57+
git checkout ${GITHUB_BASE_REF}
58+
59+
- name: Detect Added Submodules
60+
run: |
61+
BASE_REF=${{github.event.pull_request.base.sha}}
62+
git checkout $BASE_REF
63+
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..HEAD | grep '^Submodule' | awk '{ print $2 }')
64+
echo "Added submodules: $ADDED_SUBMODULES"
65+
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
66+
67+
- name: Fetch submodules
68+
run: |
69+
for submodule in $ADDED_SUBMODULES; do
70+
echo "Getting submodule: $submodule"
71+
git submodule update --init --recursive $submodule
72+
done
73+
74+
# Custom action that gets metadata on each addon
75+
- uses: dsaltares/[email protected]
76+
name: Get submodule metadata fetching action
77+
with:
78+
token: ${{ secrets.GITHUB_TOKEN }}
79+
repo: LuaLS/LLS-Addons-Action
80+
file: dist.zip
81+
target: action.zip
82+
- name: Unzip custom action
83+
run: unzip action.zip -d action
84+
- uses: ./action/dist
85+
name: Get Addon Metadata
86+
87+
# Commit new metadata
88+
- name: Commit Metadata
89+
uses: stefanzweifel/[email protected]
90+
with:
91+
commit_message: "chore: Update Addon Metadata"
92+
file_pattern: addons/*/info.json
93+
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
94+
commit_user_name: github-actions[bot]
95+
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com

0 commit comments

Comments
 (0)