@@ -9,119 +9,43 @@ permissions:
99  pull-requests : write 
1010
1111jobs :
12-   run-style-bot :
13-     if : > 
14-       contains(github.event.comment.body, '@bot /style') && 
15-       github.event.issue.pull_request != null  
16- runs-on : ubuntu-latest 
17- 
18-     steps :
19-       - name : Extract PR details 
20-         id : pr_info 
21-         uses : actions/github-script@v6 
22-         with :
23-           script : | 
24-             const prNumber = context.payload.issue.number; 
25-             const { data: pr } = await github.rest.pulls.get({ 
26-               owner: context.repo.owner, 
27-               repo: context.repo.repo, 
28-               pull_number: prNumber 
29-             }); 
30-              
31-             // We capture both the branch ref and the "full_name" of the head repo 
32-             // so that we can check out the correct repository & branch (including forks). 
33-             core.setOutput("prNumber", prNumber); 
34-             core.setOutput("headRef", pr.head.ref); 
35-             core.setOutput("headRepoFullName", pr.head.repo.full_name); 
36- 
37- name : Check out PR branch 
38-         uses : actions/checkout@v3 
39-         env : 
40-           HEADREPOFULLNAME : ${{ steps.pr_info.outputs.headRepoFullName }} 
41-           HEADREF : ${{ steps.pr_info.outputs.headRef }} 
42-         with :
43-           #  Instead of checking out the base repo, use the contributor's repo name
44-           repository : ${{ env.HEADREPOFULLNAME }} 
45-           ref : ${{ env.HEADREF }} 
46-           #  You may need fetch-depth: 0 for being able to push
47-           fetch-depth : 0 
48-           token : ${{ secrets.GITHUB_TOKEN }} 
49-       
50-       - name : Debug 
51-         env : 
52-           HEADREPOFULLNAME : ${{ steps.pr_info.outputs.headRepoFullName }} 
53-           HEADREF : ${{ steps.pr_info.outputs.headRef }} 
54-           PRNUMBER : ${{ steps.pr_info.outputs.prNumber }} 
55-         run : | 
56-           echo "PR number: $PRNUMBER" 
57-           echo "Head Ref: $HEADREF" 
58-           echo "Head Repo Full Name: $HEADREPOFULLNAME" 
59- 
60- name : Set up Python 
61-         uses : actions/setup-python@v4 
62- 
63-       - name : Install dependencies 
64-         run : | 
65-           pip install .[quality] 
66- 
67- name : Download Makefile from main branch 
68-         run : | 
69-           curl -o main_Makefile https://raw.githubusercontent.com/huggingface/diffusers/main/Makefile 
70-          
71- name : Compare Makefiles 
72-         run : | 
73-           if ! diff -q main_Makefile Makefile; then 
74-             echo "Error: The Makefile has changed. Please ensure it matches the main branch." 
75-             exit 1 
76-           fi 
77-           echo "No changes in Makefile. Proceeding..." 
78-           rm -rf main_Makefile 
79- 
80- name : Run make style and make quality 
81-         run : | 
82-           make style && make quality 
83- 
84- name : Commit and push changes 
85-         id : commit_and_push 
86-         env : 
87-           HEADREPOFULLNAME : ${{ steps.pr_info.outputs.headRepoFullName }} 
88-           HEADREF : ${{ steps.pr_info.outputs.headRef }} 
89-           PRNUMBER : ${{ steps.pr_info.outputs.prNumber }} 
90-           GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
91-         run : | 
92-           echo "HEADREPOFULLNAME: $HEADREPOFULLNAME, HEADREF: $HEADREF" 
93-           # Configure git with the Actions bot user 
94-           git config user.name "github-actions[bot]" 
95-           git config user.email "github-actions[bot]@users.noreply.github.com" 
96- 
97-           # Make sure your 'origin' remote is set to the contributor's fork 
98-           git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/$HEADREPOFULLNAME.git" 
99- 
100-           # If there are changes after running style/quality, commit them 
101-           if [ -n "$(git status --porcelain)" ]; then 
102-             git add . 
103-             git commit -m "Apply style fixes" 
104-             # Push to the original contributor's forked branch 
105-             git push origin HEAD:$HEADREF 
106-             echo "changes_pushed=true" >> $GITHUB_OUTPUT 
107-           else 
108-             echo "No changes to commit." 
109-             echo "changes_pushed=false" >> $GITHUB_OUTPUT 
110-           fi 
111- 
112- name : Comment on PR with workflow run link 
113-         if : steps.commit_and_push.outputs.changes_pushed == 'true' 
114-         uses : actions/github-script@v6 
115-         with :
116-           script : | 
117-             const prNumber = parseInt(process.env.prNumber, 10); 
118-             const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}` 
119- 
120-             await github.rest.issues.createComment({ 
121-               owner: context.repo.owner, 
122-               repo: context.repo.repo, 
123-               issue_number: prNumber, 
124-               body: `Style fixes have been applied. [View the workflow run here](${runUrl}).` 
125-             }); 
126- env :
127-           prNumber : ${{ steps.pr_info.outputs.prNumber }} 
12+   style :
13+     uses : huggingface/huggingface_hub/.github/workflows/style-bot-action.yml@main 
14+     with :
15+       python_quality_dependencies : " [quality]" 
16+       pre_commit_script_name : " Download and Compare files from the main branch" 
17+       pre_commit_script : | 
18+         echo "Downloading the files from the main branch" 
19+ 
20+         curl -o main_Makefile https://raw.githubusercontent.com/huggingface/diffusers/main/Makefile 
21+         curl -o main_setup.py https://raw.githubusercontent.com/huggingface/diffusers/refs/heads/main/setup.py 
22+         curl -o main_check_doc_toc.py https://raw.githubusercontent.com/huggingface/diffusers/refs/heads/main/utils/check_doc_toc.py 
23+ 
24+         echo "Compare the files and raise error if needed" 
25+ 
26+         diff_failed=0 
27+         if ! diff -q main_Makefile Makefile; then 
28+           echo "Error: The Makefile has changed. Please ensure it matches the main branch." 
29+           diff_failed=1 
30+         fi 
31+ 
32+         if ! diff -q main_setup.py setup.py; then 
33+           echo "Error: The setup.py has changed. Please ensure it matches the main branch." 
34+           diff_failed=1 
35+         fi 
36+ 
37+         if ! diff -q main_check_doc_toc.py utils/check_doc_toc.py; then 
38+           echo "Error: The utils/check_doc_toc.py has changed. Please ensure it matches the main branch." 
39+           diff_failed=1 
40+         fi 
41+ 
42+         if [ $diff_failed -eq 1 ]; then 
43+           echo "❌ Error happened as we detected changes in the files that should not be changed ❌" 
44+           exit 1 
45+         fi 
46+ 
47+         echo "No changes in the files. Proceeding..." 
48+         rm -rf main_Makefile main_setup.py main_check_doc_toc.py 
49+ style_command : " make style && make quality" 
50+     secrets :
51+       bot_token : ${{ secrets.GITHUB_TOKEN }} 
0 commit comments