| 1 | git-pages-cli |
| 2 | ============= |
| 3 | |
| 4 | <a href="ircs://irc.libera.chat/#git-pages"><img alt="Discuss on IRC at #git-pages on libera.chat" src="https://img.shields.io/badge/irc-libera.chat-blue"></a> |
| 5 | <a href="https://matrix.to/#/#git-pages:catircservices.org"><img alt="Discuss on Matrix at #git-pages:catircservices.org" src="https://img.shields.io/matrix/git-pages%3Acatircservices.org?server_fqdn=matrix.org&fetchMode=summary&label=matrix&color=blue"></a> |
| 6 | |
| 7 | _git-pages-cli_ is a command-line application for publishing sites to [git-pages]. |
| 8 | |
| 9 | > [!TIP] |
| 10 | > If you want to publish a site from a CI workflow, use the [Forgejo Action][git-pages-action] instead. |
| 11 | |
| 12 | [git-pages]: https://codeberg.org/git-pages/git-pages |
| 13 | [git-pages-action]: https://codeberg.org/git-pages/action |
| 14 | |
| 15 | |
| 16 | Installation |
| 17 | ------------ |
| 18 | |
| 19 | You can install _git-pages-cli_ using one of the following methods: |
| 20 | |
| 21 | 1. **Downloading a binary**. You can download the [latest build][latest] or pick a [release][releases]. |
| 22 | |
| 23 | 1. **Installing a package**. |
| 24 | |
| 25 | [](https://repology.org/project/git-pages-cli/versions) |
| 26 | |
| 27 | 1. **Using a Docker container**. Choose between the latest build or a [release tag][containers]. Then run: |
| 28 | |
| 29 | ```console |
| 30 | $ docker run --rm codeberg.org/git-pages/git-pages-cli:latest ... |
| 31 | ``` |
| 32 | |
| 33 | 1. **Installing from source**. First, install [Go](https://go.dev/) 1.25 or newer. Then run: |
| 34 | |
| 35 | ```console |
| 36 | $ go install codeberg.org/git-pages/git-pages-cli@latest |
| 37 | ``` |
| 38 | |
| 39 | [latest]: https://codeberg.org/git-pages/git-pages-cli/releases/tag/latest |
| 40 | [releases]: https://codeberg.org/git-pages/git-pages-cli/releases |
| 41 | [containers]: https://codeberg.org/git-pages/-/packages/container/git-pages-cli/versions |
| 42 | |
| 43 | |
| 44 | Usage |
| 45 | ----- |
| 46 | |
| 47 | To prepare a DNS challenge for a given site and password: |
| 48 | |
| 49 | ```console |
| 50 | $ git-pages-cli https://example.org --challenge # generate a random password |
| 51 | password: 28a616f4-2fbe-456b-8456-056d1f38e815 |
| 52 | _git-pages-challenge.example.org. 3600 IN TXT "a59ecb58f7256fc5afb6b96892501007b0b65d64f251b1aca749b0fca61d582c" |
| 53 | $ git-pages-cli https://example.org --password xyz --challenge |
| 54 | _git-pages-challenge.example.org. 3600 IN TXT "6c47172c027b3c79358f9f8c110886baf4826d9bc2a1c7d0f439cc770ed42dc8" |
| 55 | $ git-pages-cli https://example.org --password xyz --challenge-bare |
| 56 | 6c47172c027b3c79358f9f8c110886baf4826d9bc2a1c7d0f439cc770ed42dc8 |
| 57 | ``` |
| 58 | |
| 59 | To publish a site from a git repository available on the internet (`--password` may be omitted if the repository is allowlisted via DNS): |
| 60 | |
| 61 | ```console |
| 62 | $ git-pages-cli https://example.org --upload-git https://codeberg.org/username/example.org.git |
| 63 | $ git-pages-cli https://example.org --password xyz --upload-git https://codeberg.org/username/example.org.git |
| 64 | ``` |
| 65 | |
| 66 | To publish a site from a directory on your machine: |
| 67 | |
| 68 | ```console |
| 69 | $ git-pages-cli https://example.org --password xyz --upload-dir site-contents |
| 70 | ``` |
| 71 | |
| 72 | To delete a site: |
| 73 | |
| 74 | ```console |
| 75 | $ git-pages-cli https://example.org --password xyz --delete |
| 76 | ``` |
| 77 | |
| 78 | All of the operations above also accept the `--dry-run` option, which checks authorization only and doesn't perform any destructive operations: |
| 79 | |
| 80 | ```console |
| 81 | $ git-pages-cli https://example.org --password zyx --delete --dry-run |
| 82 | result: error |
| 83 | unauthorized |
| 84 | ``` |
| 85 | |
| 86 | It 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: |
| 87 | |
| 88 | ```console |
| 89 | $ git-pages-cli https://example.org --server grebedoc.dev --password xyz --upload-dir ... |
| 90 | ``` |
| 91 | |
| 92 | If enabled by the server administrator, it is possible to publish ephemeral sites that get automatically removed (e.g. in 14 days in this example): |
| 93 | |
| 94 | ```console |
| 95 | $ git-pages-cli https://example.org --password xyz --upload-dir site-contents --expires 14 |
| 96 | ``` |
| 97 | |
| 98 | ### Forge authorization |
| 99 | |
| 100 | > [!IMPORTANT] |
| 101 | > If you are using Forgejo Actions, read the documentation for [git-pages/action](https://codeberg.org/git-pages/action) first. |
| 102 | |
| 103 | Uploading 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). |
| 104 | |
| 105 | To create such an access token on Forgejo: |
| 106 | 1. Open _Settings_ > _Applications_ > _Access tokens_. |
| 107 | 1. Expand _Select permissions_, then pick _Read_ under _user_ and _Read and write_ under _repository_. |
| 108 | 1. Set _Token name_ to something informative (e.g. "git-pages publishing"). |
| 109 | 1. Click _Generate token_. |
| 110 | 1. The token will appear in a notification (a long string of hexadecimal numbers all on its own). |
| 111 | |
| 112 | To deploy using an access token: |
| 113 | |
| 114 | ```console |
| 115 | $ git-pages-cli https://username.grebedoc.dev --token <token> --upload-dir ... |
| 116 | ``` |
| 117 | |
| 118 | **Keep the access token safe and secure!** Anyone who has it will be able to change the data in any of your repositories. |
| 119 | |
| 120 | ### Specifying secrets |
| 121 | |
| 122 | While secrets may be specified using the command-line arguments `--password` and `--token`, this is not always desirable. The alternatives to the `--password` flag are the `--password-file` flag and the `GIT_PAGES_PASSWORD` environment variable, and the alternative to the `--token` flag is the `GIT_PAGES_TOKEN` environment variable. When both the environment variable and the command-line argument are provided, the command-line argument takes priority. |
| 123 | |
| 124 | |
| 125 | Advanced usage |
| 126 | -------------- |
| 127 | |
| 128 | To retrieve the site manifest (for debugging only: manifest schema is not versioned and **subject to change without notice**, including renaming of existing fields): |
| 129 | |
| 130 | ```console |
| 131 | $ git-pages-cli https://example.org --password xyz --debug-manifest |
| 132 | { |
| 133 | "contents": { |
| 134 | "": { |
| 135 | "type": "Directory" |
| 136 | }, |
| 137 | "index.html": { |
| 138 | "type": "InlineFile", |
| 139 | "size": "5", |
| 140 | "data": "bWVvdwo=", |
| 141 | "contentType": "text/html; charset=utf-8" |
| 142 | } |
| 143 | }, |
| 144 | "originalSize": "5", |
| 145 | "compressedSize": "5", |
| 146 | "storedSize": "0", |
| 147 | "redirects": [], |
| 148 | "headers": [], |
| 149 | "problems": [] |
| 150 | } |
| 151 | ``` |
| 152 | |
| 153 | |
| 154 | License |
| 155 | ------- |
| 156 | |
| 157 | [0-clause BSD](LICENSE.txt) |