Skip to content

Commit c35f3d6

Browse files
authored
Update ci (#194)
* fix: gh action * fix: fetch base and head * ci: give write permissions * ci: split actions
1 parent 071d1c6 commit c35f3d6

File tree

2 files changed

+69
-57
lines changed

2 files changed

+69
-57
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: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ jobs:
1717

1818
- name: Fetch Base Branch
1919
run: |
20-
git fetch origin ${GITHUB_BASE_REF}
21-
git checkout ${GITHUB_BASE_REF}
20+
# Fetch all history for the base branch and PR head
21+
git fetch origin ${{ github.base_ref }} --depth=1
22+
git fetch origin ${{ github.head_ref }} --depth=1
2223
2324
- name: Detect Added Submodules
2425
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 }')
26+
BASE_REF=${{ github.event.pull_request.base.sha }}
27+
HEAD_REF=${{ github.event.pull_request.head.sha }}
28+
29+
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..${HEAD_REF} | grep '^Submodule' | awk '{ print $2 }')
2830
echo "Added submodules: $ADDED_SUBMODULES"
2931
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
3032
@@ -41,55 +43,3 @@ jobs:
4143
token: ${{ secrets.GITHUB_TOKEN }}
4244
version: latest
4345
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/fetch-gh-release-asset@1.1.0
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/git-auto-commit-action@v4.16.0
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)