-
Notifications
You must be signed in to change notification settings - Fork 42
59 lines (51 loc) · 2.19 KB
/
deploy-circleci.yml
File metadata and controls
59 lines (51 loc) · 2.19 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Setup CircleCI Context and Secrets
on:
push:
branches: [main]
paths:
- '.github/workflows/**'
- '.circleci/config.yml'
workflow_dispatch:
jobs:
setup-circleci:
runs-on: ubuntu-latest
steps:
- name: Install CircleCI CLI
run: |
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | sudo bash
- name: Setup CircleCI CLI
run: |
circleci setup --no-prompt --host=https://circleci.com --token=${{ secrets.CIRCLECI_TOKEN }}
- name: Check and Delete CircleCI Context
run: |
if circleci context list --org-id ${{ secrets.CIRCLECI_ORG_ID }} | grep -q "checkincontext"; then
circleci context delete --org-id ${{ secrets.CIRCLECI_ORG_ID }} checkincontext --force
else
echo "Context does not exist, skipping deletion"
fi
- name: Create CircleCI Context
run: |
circleci context create --org-id ${{ secrets.CIRCLECI_ORG_ID }} checkincontext
- name: Migrate Secrets to CircleCI Context
env:
ORG_ID: ${{ secrets.CIRCLECI_ORG_ID }}
run: |
# Function to safely store a secret using temp txt file
store_secret() {
local secret_name=$1
local secret_value=$2
# Check if the secret value is not empty
if [ -n "$secret_value" ]; then
echo "Storing secret: $secret_name"
echo "$secret_value" | circleci context store-secret --org-id "${{ secrets.CIRCLECI_ORG_ID }}" checkincontext "${secret_name}"
else
echo "Skipping $secret_name: secret is empty or not set"
fi
}
# List of secrets to migrate
store_secret "TELEGRAM_TOKEN" "${{ secrets.TELEGRAM_TOKEN }}"
store_secret "TELEGRAM_CHAT_ID" "${{ secrets.TELEGRAM_CHAT_ID }}"
store_secret "NODESEEK_COOKIE" "${{ secrets.NODESEEK_COOKIE }}"
store_secret "V2EX_COOKIE" "${{ secrets.V2EX_COOKIE }}"
store_secret "ONEPOINT3ACRES_COOKIE" "${{ secrets.ONEPOINT3ACRES_COOKIE }}"
store_secret "TWOCAPTCHA_APIKEY" "${{ secrets.TWOCAPTCHA_APIKEY }}"