Skip to content

Commit a9ab19b

Browse files
authored
Update extract-classnames.yml
1 parent 81c5f9f commit a9ab19b

File tree

1 file changed

+16
-54
lines changed

1 file changed

+16
-54
lines changed

.github/workflows/extract-classnames.yml

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
- "features/**.js"
77
workflow_dispatch:
88

9-
permissions: {}
9+
permissions:
10+
contents: write
11+
pull-requests: write
1012

1113
jobs:
1214
extract:
@@ -24,63 +26,23 @@ jobs:
2426
- name: Run extraction script
2527
run: node .github/scripts/extract-classnames.js
2628

27-
- name: Check for changes in class-names.json
28-
id: check_changes
29+
- name: Check for changes
30+
id: git-diff
2931
run: |
3032
if git diff --quiet --exit-code class-names.json; then
3133
echo "changed=false" >> $GITHUB_OUTPUT
3234
else
3335
echo "changed=true" >> $GITHUB_OUTPUT
3436
fi
3537
36-
- name: Configure Git to use bot token
37-
if: steps.check_changes.outputs.changed == 'true'
38-
env:
39-
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
40-
run: |
41-
git config user.name "your-bot-username"
42-
git config user.email "[email protected]"
43-
git remote set-url origin https://x-access-token:${BOT_TOKEN}@github.com/${{ github.repository }}
44-
git fetch origin main
45-
git checkout -B update-class-names origin/main
46-
47-
- name: Commit changes
48-
if: steps.check_changes.outputs.changed == 'true'
49-
run: |
50-
git add class-names.json
51-
git commit -m "Update class-names.json" || echo "No changes to commit"
52-
53-
- name: Push update-class-names branch
54-
if: steps.check_changes.outputs.changed == 'true'
55-
env:
56-
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
57-
run: |
58-
git push origin update-class-names --force
59-
60-
- name: Create or update pull request
61-
if: steps.check_changes.outputs.changed == 'true'
62-
env:
63-
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
64-
REPO: ${{ github.repository }}
65-
run: |
66-
PR_EXISTS=$(curl -s -H "Authorization: token ${BOT_TOKEN}" \
67-
-H "Accept: application/vnd.github.v3+json" \
68-
"https://api.github.com/repos/${REPO}/pulls?head=${{ github.repository_owner }}:update-class-names" | jq 'length')
69-
70-
if [ "$PR_EXISTS" -eq 0 ]; then
71-
# Create PR if none exists
72-
curl -s -X POST \
73-
-H "Authorization: token ${BOT_TOKEN}" \
74-
-H "Accept: application/vnd.github.v3+json" \
75-
"https://api.github.com/repos/${REPO}/pulls" \
76-
-d @- <<EOF
77-
{
78-
"title": "Update class-names.json",
79-
"head": "update-class-names",
80-
"base": "main",
81-
"body": "Automated update of class-names.json"
82-
}
83-
EOF
84-
else
85-
echo "PR already exists, no need to create."
86-
fi
38+
- name: Create or Update Pull Request
39+
if: steps.git-diff.outputs.changed == 'true'
40+
uses: peter-evans/create-pull-request@v6
41+
with:
42+
commit-message: "Update class-names.json"
43+
branch: update-class-names
44+
title: "Update class names"
45+
body: "Automated update of class-names.json"
46+
labels: automated
47+
assignees: rgantzos
48+
delete-branch: true

0 commit comments

Comments
 (0)