-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-github-token.sh
More file actions
executable file
·42 lines (34 loc) · 1023 Bytes
/
Copy pathsetup-github-token.sh
File metadata and controls
executable file
·42 lines (34 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Script to store GitHub token in AWS Secrets Manager
echo "=== GitHub Token Setup for CodePipeline ==="
echo ""
echo "You need a GitHub Personal Access Token with 'repo' scope."
echo "Create one at: https://github.com/settings/tokens"
echo ""
read -sp "Enter your GitHub Personal Access Token: " GITHUB_TOKEN
echo ""
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: Token cannot be empty"
exit 1
fi
echo "Storing token in AWS Secrets Manager..."
aws secretsmanager create-secret \
--name github-token \
--description "GitHub token for CodePipeline" \
--secret-string "$GITHUB_TOKEN" 2>/dev/null
if [ $? -eq 0 ]; then
echo "✓ Token stored successfully!"
else
echo "Token already exists, updating..."
aws secretsmanager update-secret \
--secret-id github-token \
--secret-string "$GITHUB_TOKEN"
if [ $? -eq 0 ]; then
echo "✓ Token updated successfully!"
else
echo "✗ Failed to store token"
exit 1
fi
fi
echo ""
echo "You can now deploy the pipeline stacks."