From dc2df03919cdd9218850cedc65ce1721ed771d41 Mon Sep 17 00:00:00 2001 From: Sanja Date: Fri, 1 Mar 2024 09:44:11 -0800 Subject: [PATCH] Create Github Action to generate index file --- .github/workflows/blank.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000..500d229 --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,43 @@ +name: Generate Index + +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + push: + branches: + - "**" + pull_request: + types: [opened, reopened, synchronize, edited] + +jobs: + build: + name: "Generate index and readme" + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + ref: ${{github.head_ref}} + + - name: Setup PHP Action + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Check committer + id: check + run: | + COMMITTER=$(git log -1 --pretty=format:'%ae') + echo "COMMITTER=$COMMITTER" >> $GITHUB_ENV + + - name: Run script + run: php .github/workflows/scripts/generate_index.php + if: env.COMMITTER != 'action@github.com' + + - name: Commit and push if it changed + run: | + git diff + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -am "Update index.json and README.md" || exit 0 + git push