Skip to content

Commit 430f493

Browse files
committed
docs: add environment setup guide for GitHub token
- .env.example template (committed, no real values) - Quick start instructions - Token generation steps - Security guidelines - VS Code integration - Troubleshooting tips .env file is in .gitignore and not committed
1 parent 8e4d58b commit 430f493

2 files changed

Lines changed: 153 additions & 0 deletions

File tree

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# GitHub Token para criar issues e fazer uploads
2+
# Gerar em: https://github.com/settings/tokens
3+
# Scopes necessários: repo, project
4+
GITHUB_TOKEN=ghp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

ENV_SETUP.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# 🔐 GitHub Token Setup
2+
3+
## ⚡ Quick Start
4+
5+
### 1️⃣ Criar arquivo `.env`
6+
7+
```bash
8+
# Copiar template
9+
cp .env.example .env
10+
11+
# Editar e adicionar seu token real
12+
nano .env
13+
# ou
14+
code .env
15+
```
16+
17+
### 2️⃣ Adicionar token do GitHub
18+
19+
```bash
20+
# Abrir .env
21+
GITHUB_TOKEN="ghp_seu_token_real_aqui"
22+
```
23+
24+
### 3️⃣ Carregar no terminal
25+
26+
```bash
27+
# No terminal do VS Code:
28+
source .env
29+
30+
# Verificar
31+
echo $GITHUB_TOKEN
32+
```
33+
34+
### 4️⃣ Rodar scripts
35+
36+
```bash
37+
python3 /tmp/create_issues.py
38+
```
39+
40+
---
41+
42+
## 🔑 Como Obter um Token
43+
44+
1. Ir para: https://github.com/settings/tokens
45+
2. Clicar **"Generate new token"****"Generate new token (classic)"**
46+
3. **Nome**: `server-setup-automation`
47+
4. **Escopos**:
48+
-`repo` - Acesso a repositórios
49+
-`project` - Ler/escrever projects
50+
5. **Expiração**: 30 ou 90 dias
51+
6. **Copiar token** (aparece apenas uma vez!)
52+
53+
---
54+
55+
## 🔒 Segurança
56+
57+
| ✅ Fazer | ❌ Evitar |
58+
|---------|----------|
59+
| `.env` com permissões `600` | Commitar `.env` no git |
60+
| Usar `source .env` | Expor token em logs |
61+
| Rotacionar mensalmente | Compartilhar token |
62+
| Escopo mínimo necessário | Token pessoal em automação |
63+
64+
---
65+
66+
## 📋 Arquivos de Configuração
67+
68+
```
69+
.env.example ← Template (commitado, sem valores reais)
70+
.env ← Seu token real (NO .gitignore, NÃO commitado)
71+
```
72+
73+
---
74+
75+
## 🚀 Integração VS Code
76+
77+
### Opção A: Terminal (Recomendado)
78+
79+
```bash
80+
# No terminal integrado do VS Code:
81+
cd /Volumes/DATA/infra/server-setup
82+
source .env
83+
echo $GITHUB_TOKEN
84+
```
85+
86+
### Opção B: Automático (Editar `~/.zshrc`)
87+
88+
```bash
89+
# Adicionar ao ~/.zshrc:
90+
if [ -f "$PWD/.env" ]; then
91+
source "$PWD/.env"
92+
fi
93+
94+
# Recarregar:
95+
source ~/.zshrc
96+
```
97+
98+
---
99+
100+
## ✅ Verificação
101+
102+
```bash
103+
# 1. Verificar se arquivo existe
104+
ls -la .env
105+
106+
# 2. Verificar permissões (deve ser 600)
107+
ls -l .env
108+
# -rw------- ...
109+
110+
# 3. Verificar token carregado
111+
echo $GITHUB_TOKEN
112+
# Deve mostrar: ghp_xxxxxxxxxxxxx
113+
114+
# 4. Testar criação de issue
115+
python3 /tmp/create_issues.py
116+
```
117+
118+
---
119+
120+
## 🆘 Troubleshooting
121+
122+
### Token não aparece
123+
```bash
124+
# Verificar se arquivo existe
125+
test -f .env && echo "Existe" || echo "Não existe"
126+
127+
# Carregar novamente
128+
source .env
129+
130+
# Verificar conteúdo
131+
cat .env
132+
```
133+
134+
### Permissão negada
135+
```bash
136+
# Deve ser leitura/escrita apenas para você
137+
chmod 600 .env
138+
```
139+
140+
### Token expirou
141+
```bash
142+
# Gerar novo em: https://github.com/settings/tokens
143+
# Atualizar .env
144+
nano .env
145+
```
146+
147+
---
148+
149+
**Última atualização**: 2025-12-30

0 commit comments

Comments
 (0)