Skip to content

Commit 3cb24db

Browse files
committed
testing
1 parent a8ec856 commit 3cb24db

File tree

1 file changed

+108
-3
lines changed

1 file changed

+108
-3
lines changed

Diff for: .github/workflows/update_all_user_environments.yaml

+108-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ on:
44
pull_request:
55
branches: [main]
66

7+
8+
env:
9+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
10+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11+
AWS_REGION: us-east-1
12+
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
13+
ECR_REPOSITORY: ld-core-demo
14+
KUBECTL_VERSION: "v1.23.0"
15+
LD_API_KEY: ${{ secrets.LD_API_KEY }}
16+
717
jobs:
8-
update-demo-environments:
18+
get-all-demo-environments:
919
runs-on: ubuntu-latest
1020
steps:
1121
- name: Checkout repository
@@ -18,6 +28,101 @@ jobs:
1828
branch=${branch#origin/}
1929
if [[ $branch == *demoenv* ]]; then
2030
echo "Branch $branch is a demo environment"
21-
echo "Updating environment for branch $branch"
31+
branches_to_update+=($branch)
2232
fi
23-
done
33+
done
34+
echo "BRANCHES=${branches_to_update[@]}" >> $GITHUB_ENV
35+
36+
update-all-demo-environments:
37+
needs: get-all-demo-environments
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
42+
43+
- name: Update all demo environments
44+
run: |
45+
for branch in "${branches_to_update[@]}"; do
46+
echo "Updating branch $branch"
47+
git checkout $branch
48+
git pull origin $branch
49+
get merge origin/main --no-edit
50+
done
51+
52+
- name: Get Namespaces
53+
id: get-namespaces
54+
run: |
55+
for branch in "${branches_to_update[@]}"; do
56+
NAMESPACE=${branch#demoenv-}
57+
echo "NAMESPACE=${NAMESPACE}" >> $GITHUB_ENV
58+
done
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v2
62+
with:
63+
python-version: "3.9"
64+
65+
- name: Install dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
pip install -r ./.github/workflows/requirements.txt
69+
70+
- name: Get LD Env Vars for Demo Environment
71+
id: create_ld_project
72+
env:
73+
LD_API_KEY: ${{ secrets.LD_API_KEY }}
74+
NAMESPACE: ${{ env.DEMO_NAMESPACE }}
75+
run: |
76+
echo "Creating LaunchDarkly project for namespace: ${{ env.DEMO_NAMESPACE }}"
77+
python ./.github/workflows/create_ld_project.py
78+
79+
- name: Create .env file
80+
run: |
81+
touch ./.env.production
82+
echo NEXT_PUBLIC_LD_CLIENT_KEY=${{ env.LD_CLIENT_KEY }} >> ./.env.production
83+
echo LD_SDK_KEY=${{ env.LD_SDK_KEY }} >> ./.env.production
84+
echo DB_URL=${{ secrets.DB_URL }} >> ./.env.production
85+
echo LD_API_KEY=${{ secrets.LD_API_KEY }} >> ./.env.production
86+
echo DESTINATIONENV=${{ env.DEMO_NAMESPACE }} >> ./.env.production
87+
echo PROJECT_KEY=${{ env.DEMO_NAMESPACE }}-ld-demo >> ./.env.production
88+
89+
- name: Login to Amazon ECR
90+
id: login-ecr
91+
uses: aws-actions/amazon-ecr-login@v1
92+
93+
- name: Build, tag, and push image to Amazon ECR
94+
env:
95+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
96+
ECR_REPOSITORY: ld-core-demo
97+
run: |
98+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ env.DEMO_NAMESPACE }}-${{ github.run_id }} .
99+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ env.DEMO_NAMESPACE }}-${{ github.run_id }}
100+
101+
- name: Update K8s Deploy File
102+
run: python ./.github/workflows/update_k8s_deploy_file.py
103+
env:
104+
NAMESPACE: ${{ env.DEMO_NAMESPACE }}
105+
URL: ${{ env.DEMO_NAMESPACE }}.launchdarklydemos.com
106+
IMAGE: ${{ steps.login-ecr.outputs.registry }}/ld-core-demo:${{ env.DEMO_NAMESPACE }}-${{ github.run_id }}
107+
108+
- name: Check Namespace in Kubernetes
109+
uses: kodermax/kubectl-aws-eks@master
110+
with:
111+
args: get namespace ${{ env.DEMO_NAMESPACE }} &>/dev/null && echo "namespace_exists=true" >> $GITHUB_ENV || echo "namespace_exists=false" >> $GITHUB_ENV
112+
113+
- name: Create Namespace In Kubernetes
114+
if: env.namespace_exists == 'false'
115+
uses: kodermax/kubectl-aws-eks@master
116+
with:
117+
args: create namespace ${{ env.DEMO_NAMESPACE }}
118+
119+
- name: Applying deploy file to Kubernetes
120+
uses: kodermax/kubectl-aws-eks@master
121+
with:
122+
args: apply -f ./.github/workflows/deploy_files/deploy.yaml -n ${{ env.DEMO_NAMESPACE }}
123+
124+
- name: Delete the deploy file
125+
run: rm -rf ./.github/workflows/deploy_files
126+
127+
- name: Remove .env file
128+
run: rm ./.env.production

0 commit comments

Comments
 (0)