From c37edfcdf85b968b07e750bf5df11cb19106d225 Mon Sep 17 00:00:00 2001 From: carsakiller Date: Mon, 25 Nov 2024 20:45:40 +0000 Subject: [PATCH 1/4] fix: gh action --- .github/workflows/pull_request.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ac097a0..c11fb4b 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -23,7 +23,6 @@ jobs: - name: Detect Added Submodules run: | BASE_REF=${{github.event.pull_request.base.sha}} - git checkout $BASE_REF ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..HEAD | grep '^Submodule' | awk '{ print $2 }') echo "Added submodules: $ADDED_SUBMODULES" echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV @@ -59,7 +58,6 @@ jobs: - name: Detect Added Submodules run: | BASE_REF=${{github.event.pull_request.base.sha}} - git checkout $BASE_REF ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..HEAD | grep '^Submodule' | awk '{ print $2 }') echo "Added submodules: $ADDED_SUBMODULES" echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV From b3115caf11c0da66ac3b43fa61a307e8df64110f Mon Sep 17 00:00:00 2001 From: carsakiller Date: Mon, 25 Nov 2024 20:45:41 +0000 Subject: [PATCH 2/4] fix: fetch base and head --- .github/workflows/pull_request.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c11fb4b..3767208 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,13 +17,16 @@ jobs: - name: Fetch Base Branch run: | - git fetch origin ${GITHUB_BASE_REF} - git checkout ${GITHUB_BASE_REF} + # Fetch all history for the base branch and PR head + git fetch origin ${{ github.base_ref }} --depth=1 + git fetch origin ${{ github.head_ref }} --depth=1 - name: Detect Added Submodules run: | - BASE_REF=${{github.event.pull_request.base.sha}} - ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..HEAD | grep '^Submodule' | awk '{ print $2 }') + BASE_REF=${{ github.event.pull_request.base.sha }} + HEAD_REF=${{ github.event.pull_request.head.sha }} + + 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 @@ -52,13 +55,16 @@ jobs: - name: Fetch Base Branch run: | - git fetch origin ${GITHUB_BASE_REF} - git checkout ${GITHUB_BASE_REF} + # Fetch all history for the base branch and PR head + git fetch origin ${{ github.base_ref }} --depth=1 + git fetch origin ${{ github.head_ref }} --depth=1 - name: Detect Added Submodules run: | - BASE_REF=${{github.event.pull_request.base.sha}} - ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..HEAD | grep '^Submodule' | awk '{ print $2 }') + BASE_REF=${{ github.event.pull_request.base.sha }} + HEAD_REF=${{ github.event.pull_request.head.sha }} + + 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 From 260bebe13f36559cdedbbec5d5866a4323de2f4f Mon Sep 17 00:00:00 2001 From: carsakiller Date: Mon, 25 Nov 2024 20:45:42 +0000 Subject: [PATCH 3/4] ci: give write permissions --- .github/workflows/pull_request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 3767208..ab65d59 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -47,6 +47,8 @@ jobs: metadata: name: "Fetch Addon Metadata" runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: actions/checkout@v3 name: Checkout LLS-Addons From bff2627e5085b6dd9138e159865b902968dba66b Mon Sep 17 00:00:00 2001 From: carsakiller Date: Mon, 25 Nov 2024 20:45:42 +0000 Subject: [PATCH 4/4] ci: split actions --- .github/workflows/metadata.yml | 62 ++++++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 56 --------------------------- 2 files changed, 62 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/metadata.yml diff --git a/.github/workflows/metadata.yml b/.github/workflows/metadata.yml new file mode 100644 index 0000000..fff466c --- /dev/null +++ b/.github/workflows/metadata.yml @@ -0,0 +1,62 @@ +name: Fetch Addon Metadata + +on: + pull_request_review: + types: [submitted] + +jobs: + metadata: + if: ${{ github.event.review.state == 'approved' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + name: Checkout LLS-Addons + with: + submodules: false + + - name: Fetch Base Branch + run: | + # Fetch all history for the base branch and PR head + git fetch origin ${{ github.base_ref }} --depth=1 + git fetch origin ${{ github.head_ref }} --depth=1 + + - name: Detect Added Submodules + run: | + BASE_REF=${{ github.event.pull_request.base.sha }} + HEAD_REF=${{ github.event.pull_request.head.sha }} + + 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/fetch-gh-release-asset@1.1.0 + 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/git-auto-commit-action@v4.16.0 + 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 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ab65d59..9fca037 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -43,59 +43,3 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} version: latest args: --check addons - - metadata: - name: "Fetch Addon Metadata" - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - name: Checkout LLS-Addons - with: - submodules: false - - - name: Fetch Base Branch - run: | - # Fetch all history for the base branch and PR head - git fetch origin ${{ github.base_ref }} --depth=1 - git fetch origin ${{ github.head_ref }} --depth=1 - - - name: Detect Added Submodules - run: | - BASE_REF=${{ github.event.pull_request.base.sha }} - HEAD_REF=${{ github.event.pull_request.head.sha }} - - 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/fetch-gh-release-asset@1.1.0 - 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/git-auto-commit-action@v4.16.0 - 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