Skip to content

Commit c1761a4

Browse files
authored
Adds required permission for GitHub deployment
Based on the discussions in https://github.com/orgs/statiqdev/discussions/221 as well as in statiqdev/Statiq.Web#1021 the documentation is updated.
1 parent 5afa33f commit c1761a4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

input/guide/deployment/github-pages.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Badge: Web
22
---
33
Statiq can be configured to deploy to [GitHub Pages](https://pages.github.com).
44

5-
Note that GitHub Pages must be activated for the target repository [according to the instructions](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site) before deploying to it.
5+
Note that GitHub Pages must be activated for the target repository [according to the instructions](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site) before deploying to it. Using the deployment pipeline described here requires that GitHub Pages are configured to be published from a branch [like described here](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch).
66

77
The following [settings](xref:web-settings) are used to configure deployment to GitHub Pages:
88

@@ -11,7 +11,7 @@ The following [settings](xref:web-settings) are used to configure deployment to
1111
- `GitHubUsername`: The username to use for deployment.
1212
- `GitHubPassword`: The password to use for deployment.
1313
- `GitHubToken`: The token to use for deployment (configure either this _or_ username and password). If deploying from a GitHub Action (see below), you should use a [computed value](xref:metadata-values#computed-values) to get the value of "GITHUB_TOKEN" for this value: `=> Config.FromSetting<string>("GITHUB_TOKEN")`.
14-
- `GitHubBranch`: The branch to deploy to (defaults to `gh-pages` but you should change this to the configured GitHub Pages branch such as `main` or `master` for organization sites).
14+
- `GitHubBranch`: The branch to deploy to (defaults to `gh-pages` but you should change this to the configured GitHub Pages branch such as `main` or `master` for organization sites). Be aware that the generated site will be pushed into this branch!
1515

1616
It's customary to set one or more of these settings as an environment variable in continuous
1717
integration environments (particularly secrets like the password). In these scenarios you can either
@@ -70,6 +70,10 @@ to deploy a Statiq site:
7070
name: Deploy Site
7171
on: [push]
7272

73+
# Sets permissions of the GITHUB_TOKEN to allow writing the content to the branch!
74+
permissions:
75+
contents: write
76+
7377
jobs:
7478
build:
7579
runs-on: windows-latest
@@ -89,4 +93,6 @@ jobs:
8993
Note that you don't need to call `DeployToGitHubPages` or `DeployToGitHubPagesBranch` if you're specifying the
9094
`GitHubOwner`, `GitHubName`, `GitHubToken`, (and optionally `GitHubBranch`)
9195
settings elsewhere (like an `appsettings.json` file). These methods are just a convenience for setting those values. The
92-
GitHub deployment will automatically take place if those settings are defined, regardless of how or where they were set.
96+
GitHub deployment will automatically take place if those settings are defined, regardless of how or where they were set.
97+
98+
Keep in mind that although this approach can use a GitHub Action (as shown above), there is an alternative way of using GitHub Actions for deployment to GitHub pages.

0 commit comments

Comments
 (0)