Merge pull request #31 from lucafoscili/version-bump-rc #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Component Count | |
on: | |
push: | |
branches: | |
- candidate | |
jobs: | |
update-count: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup Authentication | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | |
- name: Fetch All Branches | |
run: git fetch --all | |
- name: Checkout or Create Component Count Update Branch | |
run: | | |
if git show-ref --verify --quiet refs/heads/component-count-update; then | |
git checkout component-count-update | |
git merge origin/candidate | |
else | |
git checkout -b component-count-update origin/candidate | |
fi | |
- name: Count Components | |
id: count | |
run: | | |
COUNT=$(ls -l packages/components/src/components | grep '^d' | wc -l) | |
echo "{ \"components\": $COUNT }" > count.json | |
echo "components=$COUNT" >> $GITHUB_OUTPUT | |
- name: Check for Changes | |
id: git-check | |
run: | | |
if git diff --quiet; then | |
echo "changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit Component Count | |
if: steps.git-check.outputs.changes == 'true' | |
run: | | |
git add count.json | |
git commit -m "Update component count to ${{ steps.count.outputs.components }} [skip ci]" || echo "No changes to commit" | |
- name: Push Changes to Branch | |
if: steps.git-check.outputs.changes == 'true' | |
run: git push origin component-count-update | |
- name: Create or Update Pull Request | |
if: steps.git-check.outputs.changes == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: "Update component count" | |
branch: "component-count-update" | |
title: "Update component count" | |
body: "Automatically updates the component count." | |
base: "candidate" | |
labels: "automated PR" |