[mirror] Command-line application for uploading a site to a git-pages server
1git-pages-cli
2=============
3
4_git-pages-cli_ is a command-line application for publishing sites to [git-pages].
5
6> [!TIP]
7> If you want to publish a site from a CI workflow, use the [Forgejo Action][git-pages-action] instead.
8
9[git-pages]: https://codeberg.org/git-pages/git-pages
10[git-pages-action]: https://codeberg.org/git-pages/action
11
12
13Installation
14------------
15
16You can install _git-pages-cli_ using one of the following methods:
17
181. **Downloading a binary**. You can download the [latest build][latest] or pick a [release][releases].
19
201. **Using a Docker container**. Choose between the latest build or a [release tag][containers]. Then run:
21
22 ```console
23 $ docker run --rm codeberg.org/git-pages/git-pages-cli:latest ...
24 ```
25
261. **Installing from source**. First, install [Go](https://go.dev/) 1.25 or newer. Then run:
27
28 ```console
29 $ go install codeberg.org/git-pages/git-pages-cli@latest
30 ```
31
32[latest]: https://codeberg.org/git-pages/git-pages-cli/releases/tag/latest
33[releases]: https://codeberg.org/git-pages/git-pages-cli/releases
34[containers]: https://codeberg.org/git-pages/-/packages/container/git-pages-cli/versions
35
36
37Usage
38-----
39
40To prepare a DNS challenge for a given site and password:
41
42```console
43$ git-pages-cli https://example.org --challenge # generate a random password
44password: 28a616f4-2fbe-456b-8456-056d1f38e815
45_git-pages-challenge.example.org. 3600 IN TXT "a59ecb58f7256fc5afb6b96892501007b0b65d64f251b1aca749b0fca61d582c"
46$ git-pages-cli https://example.org --password xyz --challenge
47_git-pages-challenge.example.org. 3600 IN TXT "6c47172c027b3c79358f9f8c110886baf4826d9bc2a1c7d0f439cc770ed42dc8"
48$ git-pages-cli https://example.org --password xyz --challenge-bare
496c47172c027b3c79358f9f8c110886baf4826d9bc2a1c7d0f439cc770ed42dc8
50```
51
52To publish a site from a git repository available on the internet (`--password` may be omitted if the repository is allowlisted via DNS):
53
54```console
55$ git-pages-cli https://example.org --upload-git https://codeberg.org/username/example.org.git
56$ git-pages-cli https://example.org --password xyz --upload-git https://codeberg.org/username/example.org.git
57```
58
59To publish a site from a directory on your machine:
60
61```console
62$ git-pages-cli https://example.org --password xyz --upload-dir site-contents
63```
64
65To delete a site:
66
67```console
68$ git-pages-cli https://example.org --password xyz --delete
69```
70
71It is not possible to publish a site to a domain for the first time using HTTPS, since the git-pages server is not allowed to acquire a TLS certificate for a domain before a site is published on that domain. Either use plain HTTP instead, or provide a hostname for which the server *does* have a TLS certificate using the `--server` option:
72
73```console
74$ git-pages-cli https://example.org --server grebedoc.dev --password xyz --upload-dir ...
75```
76
77### Forge authorization
78
79Uploading a directory to a site on a wildcard domain (e.g. `https://<owner>.grebedoc.dev/<repo>`) requires the use of an access token with push permissions for the corresponding repository (`https://codeberg.org/<owner>/<repo>.git` in this case).
80
81To create such an access token on Forgejo:
821. Open _Settings_ > _Applications_ > _Access tokens_.
831. Expand _Select permissions_, pick _Read and write_ under _repository_.
841. Set _Token name_ to something informative (e.g. "git-pages publishing").
851. Click _Generate token_.
861. The token will appear in a notification (a long string of hexadecimal numbers all on its own).
87
88To deploy using an access token:
89
90```console
91$ git-pages-cli https://username.grebedoc.dev --token <token> --upload-dir ...
92```
93
94**Keep the access token safe and secure!** Anyone who has it will be able to change the data in any of your repositories.
95
96
97Advanced usage
98--------------
99
100To retrieve the site manifest (for debugging only: manifest schema is not versioned and **subject to change without notice**, including renaming of existing fields):
101
102```console
103$ git-pages-cli https://example.org --password xyz --debug-manifest
104{
105 "contents": {
106 "": {
107 "type": "Directory"
108 },
109 "index.html": {
110 "type": "InlineFile",
111 "size": "5",
112 "data": "bWVvdwo=",
113 "contentType": "text/html; charset=utf-8"
114 }
115 },
116 "originalSize": "5",
117 "compressedSize": "5",
118 "storedSize": "0",
119 "redirects": [],
120 "headers": [],
121 "problems": []
122}
123```
124
125
126License
127-------
128
129[0-clause BSD](LICENSE.txt)