Skip to content

added elipse back

added elipse back #7

name: "Build and Deploy Images to Test Environment"
on:
pull_request:
branches: [main]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
ECR_REPOSITORY: ld-core-demo
KUBECTL_VERSION: "v1.23.0"
LD_API_KEY: ${{ secrets.LD_API_KEY }}
jobs:
deploy-to-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./.github/workflows/requirements.txt
- name: Get LD ENVs
id: get-envs
run: |
echo "var1=$(python ./.github/workflows/get_ld_values.py | sed -n '1p')" >> $GITHUB_ENV
echo "var2=$(python ./.github/workflows/get_ld_values.py | sed -n '2p')" >> $GITHUB_ENV
env:
LD_ENV_KEY: test
LD_API_KEY: ${{ secrets.LD_API_KEY }}
- name: Create .env file
run: |
touch ./.env.production
echo NEXT_PUBLIC_LD_CLIENT_KEY=${{ env.var2 }} >> ./.env.production
echo LD_SDK_KEY=${{ env.var1 }} >> ./.env.production
echo DB_URL=${{ secrets.DB_URL }} >> ./.env.production
echo LD_API_KEY=${{ secrets.LD_API_KEY }} >> ./.env.production
echo DESTINATIONENV=test >> ./.env.production
echo PROJECT_KEY=ld-core-demo >> ./.env.production
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ld-core-demo
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:test-${{ github.run_number }} .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:test-${{ github.run_number }}
- name: Update K8s Deploy File
run: python ./.github/workflows/update_k8s_deploy_file.py
env:
NAMESPACE: test
URL: test.launchdarklydemos.com
IMAGE: ${{ steps.login-ecr.outputs.registry }}/ld-core-demo:test-${{ github.run_number }}
- name: Applying deploy file to Kubernetes
uses: kodermax/kubectl-aws-eks@master
with:
args: apply -f ./.github/workflows/deploy_files/deploy.yaml -n test
- name: Restart Pods
uses: kodermax/kubectl-aws-eks@master
env:
RELEASE_IMAGE: ${{ steps.login-ecr.outputs.registry }}/ld-core-demo:test-${{ github.run_number }}
with:
args: set image deployment/ld-core-demo-deployment ld-core-demo=${{ env.RELEASE_IMAGE }} -n test
- name: Delete the deploy file
run: rm -rf ./.github/workflows/deploy_files
- name: Remove .env file
run: rm ./.env.production