File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,13 @@ Each entry uses the format:
24
24
- ** api:** Fetches from a private GitHub repo using the GitHub API (requires ` GITHUB_TOKEN ` environment variable).
25
25
- ** ghuser:** Fetches public keys from a GitHub user's profile (provide the GitHub username after the colon).
26
26
27
+ You can also set your GitHub token in the config file using ` CONF_GITHUB_TOKEN ` .
28
+ If ` GITHUB_TOKEN ` is not set in the environment, the script will use ` CONF_GITHUB_TOKEN ` from ` users.conf ` .
29
+
27
30
** Example ` users.conf ` :**
28
31
``` bash
32
+ CONF_GITHUB_TOKEN=" your_github_token_here"
33
+
29
34
declare -A USER_KEYS=(
30
35
[" ubuntu" ]=" raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
31
36
[" devuser" ]=" api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
@@ -36,7 +41,7 @@ declare -A USER_KEYS=(
36
41
## Usage
37
42
38
43
1 . Edit the ` users.conf ` file to define users and their key URLs or GitHub usernames.
39
- 2 . If using the ` api ` method, export your GitHub token:
44
+ 2 . If using the ` api ` method, either export your GitHub token or set ` CONF_GITHUB_TOKEN ` in ` users.conf ` :
40
45
``` bash
41
46
export GITHUB_TOKEN=your_token_here
42
47
```
Original file line number Diff line number Diff line change 2
2
set -euo pipefail
3
3
4
4
# shellcheck disable=SC2034 # planned to be used in a future release
5
- SCRIPT_VERSION=" 0.0.6 "
5
+ SCRIPT_VERSION=" 0.0.7 "
6
6
7
7
# === Load user configuration ===
8
8
SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
@@ -15,6 +15,11 @@ if ! source "$SCRIPT_DIR/users.conf"; then
15
15
exit 1
16
16
fi
17
17
18
+ # Load GITHUB_TOKEN from config if set and not already in environment
19
+ if [[ -n " ${CONF_GITHUB_TOKEN:- } " && -z " ${GITHUB_TOKEN:- } " ]]; then
20
+ export GITHUB_TOKEN=" $CONF_GITHUB_TOKEN "
21
+ fi
22
+
18
23
log_message () {
19
24
local TIMESTAMP
20
25
TIMESTAMP=" $( date ' +%Y-%m-%d %H:%M:%S' ) "
Original file line number Diff line number Diff line change
1
+
2
+ CONF_GITHUB_TOKEN="your_github_token_here"
3
+
1
4
declare -A USER_KEYS=(
2
5
["ubuntu"]="raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
3
6
["devuser"]="api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
You can’t perform that action at this time.
0 commit comments