|
5 | 5 | branches: |
6 | 6 | - master |
7 | 7 |
|
8 | | -permissions: |
9 | | - contents: write # ✅ Grants write access to push changes |
10 | | - pull-requests: write # ✅ Allows creating and merging PRs |
11 | | - |
12 | 8 | jobs: |
13 | | - format-and-deploy: |
| 9 | + publish-docs: |
14 | 10 | runs-on: ubuntu-latest |
15 | 11 | steps: |
16 | 12 | - name: Checkout Repository 🛎️ |
17 | 13 | uses: actions/checkout@v4 |
18 | 14 | with: |
19 | | - persist-credentials: false # Prevents using default GitHub token |
| 15 | + persist-credentials: false |
20 | 16 |
|
21 | 17 | - name: Setup Node.js 🔧 |
22 | 18 | uses: actions/setup-node@v4 |
|
26 | 22 | - name: Install Dependencies 📦 |
27 | 23 | run: npm ci |
28 | 24 |
|
29 | | - - name: Format Code 🎨 |
30 | | - run: npm run format |
31 | | - |
32 | | - - name: Check for Code Changes 🔍 |
33 | | - id: check_changes |
34 | | - run: | |
35 | | - git add . |
36 | | - if git diff --cached --quiet; then |
37 | | - echo "No changes detected." |
38 | | - echo "changes_found=false" >> $GITHUB_ENV |
39 | | - else |
40 | | - echo "Changes detected." |
41 | | - echo "changes_found=true" >> $GITHUB_ENV |
42 | | - fi |
43 | | -
|
44 | | - - name: Create Pull Request ✨ |
45 | | - if: env.changes_found == 'true' |
46 | | - uses: peter-evans/create-pull-request@v6 |
47 | | - with: |
48 | | - token: ${{ secrets.GITHUB_TOKEN }} |
49 | | - commit-message: 'chore: Format code' |
50 | | - title: 'Code Formatting Updates' |
51 | | - body: 'This PR contains automated code formatting changes.' |
52 | | - branch: 'auto-format' |
53 | | - base: 'master' |
54 | | - delete-branch: true |
55 | | - |
56 | | - - name: Auto-Merge PR 🤖 |
57 | | - if: env.changes_found == 'true' |
58 | | - uses: actions/github-script@v7 |
59 | | - with: |
60 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
61 | | - script: | |
62 | | - const { owner, repo } = context.repo; |
63 | | - const prs = await github.rest.pulls.list({ owner, repo, head: 'auto-format' }); |
64 | | - if (prs.data.length > 0) { |
65 | | - const prNumber = prs.data[0].number; |
66 | | - await github.rest.pulls.merge({ owner, repo, pull_number: prNumber, merge_method: 'squash' }); |
67 | | - console.log(`Merged PR #${prNumber}`); |
68 | | - } |
69 | | -
|
70 | 25 | - name: Build Documentation 🏗 |
71 | 26 | run: npm run docs:build |
72 | 27 |
|
|
0 commit comments