You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+38-13Lines changed: 38 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,10 @@ on:
16
16
jobs:
17
17
sync:
18
18
runs-on: ubuntu-latest
19
+
# Optional: Add permissions for the default GITHUB_TOKEN
20
+
# permissions:
21
+
# contents: write
22
+
# workflows: write # Required to modify workflow files
19
23
steps:
20
24
- name: Checkout
21
25
uses: actions/checkout@v5
@@ -34,21 +38,18 @@ jobs:
34
38
exclude: |
35
39
README.md
36
40
LICENSE
37
-
env:
38
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41
+
# Option 1: Use default GITHUB_TOKEN (won't work for workflow files unless permissions are set above)
42
+
token: ${{ secrets.GITHUB_TOKEN }}
43
+
44
+
# Option 2: Use a PAT with workflow permissions (recommended for syncing workflow files)
45
+
# token: ${{ secrets.PAT_WITH_WORKFLOW_SCOPE }}
39
46
```
40
47
41
48
## Inputs
42
49
43
50
| Input | Description | Required | Default |
44
51
|-------|-------------|----------|---------|
45
-
| `template-repository` | Repository to sync from | Yes | - |
46
-
| `template-branch` | Branch to sync from in the template repo | No | `main` |
47
-
| `branch` | Branch to sync changes to in the target repo | No | `sync/update-configs` |
48
-
| `commit-message` | Commit message for sync | No | `chore: sync template` |
49
-
| `include` | List of files and folders to include (multi-line) | No | See action.yml |
50
-
| `exclude` | List of files and folders to exclude (multi-line) | No | See action.yml |
51
-
| `token` | Token to use for authentication | No | `${{ github.token }}` |
52
+
52
53
53
54
## How It Works
54
55
@@ -58,8 +59,33 @@ This action performs the following steps:
58
59
2. Removes excluded files/folders from the template
59
60
3. Copies the template files into the target repository
60
61
4. Commits and pushes the changes to the specified branch in the target repository
62
+
5. Optionally creates a pull request for the changes
63
+
64
+
The action uses sparse checkout to minimize the amount of data that needs to be downloaded, making it efficient even with large template repositories.
65
+
66
+
The pull request creation step uses GitHub's REST API to check if a PR already exists for the branch and creates one if needed. This ensures that multiple workflow runs don't create duplicate PRs.
67
+
68
+
### GitHub Token Permissions
69
+
70
+
When using this action to sync workflow files (files in `.github/workflows/`), you need to be aware of GitHub's token permission restrictions:
71
+
72
+
1.**Default `GITHUB_TOKEN`**: Does not have permission to update workflow files in a repository. If you try to sync workflow files using the default token, you'll get an error like:
73
+
```
74
+
! [remote rejected] HEAD -> sync/update (refusing to allow a GitHub App to create or update workflow without `workflows` permission)
75
+
```
76
+
77
+
2.**Personal Access Token (PAT)**: To sync workflow files, you must use a PAT with the `workflow` scope. Configure this in your workflow:
78
+
```yaml
79
+
with:
80
+
token: ${{ secrets.PAT_WITH_WORKFLOW_SCOPE }}
81
+
```
82
+
83
+
3. **Repository Settings**: Alternatively, you can modify the default token permissions in your repository settings:
84
+
- Go to Settings > Actions > General
85
+
- Under "Workflow permissions", select "Read and write permissions"
86
+
- Check "Allow GitHub Actions to create and approve pull requests"
61
87
62
-
The action uses sparse checkout to minimize the amount of data that needs to be downloaded, making it efficient even with large template repositories.
88
+
The action will automatically detect when workflow files are being modified and provide appropriate warnings.
0 commit comments