1
0
mirror of https://github.com/getlago/lago.git synced 2025-02-23 13:11:57 +07:00

cd: add front deployment

This commit is contained in:
Jeremy Denquin 2022-03-22 15:27:02 +01:00
parent 5b3b0a4865
commit d182982006
No known key found for this signature in database
GPG Key ID: 9E2B6D4E714D5CE0

View File

@ -11,17 +11,82 @@ on:
required: true
default: 'main'
jobs:
deploy-front:
build-front-image:
name: Deploy Front
runs-on: ubuntu-latest
steps:
- name: Front Repository Dispatch
uses: peter-evans/repository-dispatch@v1
- name: Checkout Front
uses: actions/checkout@v3
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: getlago/lago-front
event-type: deploy-preview
client-payload: '{ "branch": "${{ github.event.inputs.front_branch }}" }'
ref: ${{ github.event.inputs.front_branch }}
path: front
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- 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: lago-front-staging
IMAGE_TAG: ${{ github.event.inputs.front_branch }}
API_URL: https://${{ github.event.inputs.front_branch }}-api.staging.getlago.com
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg API_URL=$API_URL ./front
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
front-deploy:
name: Deploy Front
runs-on: ubuntu-latest
container:
image: getlago/deploy-staging
needs: [build-front-image]
env:
PORTER_HOST: https://dashboard.getporter.dev
PORTER_CLUSTER: ${{ secrets.PORTER_CLUSTER }}
PORTER_PROJECT: ${{ secrets.PORTER_PROJECT }}
PORTER_TOKEN: ${{ secrets.PORTER_TOKEN_2643 }}
steps:
- name: Checkout Front
uses: actions/checkout@v3
with:
repository: getlago/lago-front
ref: ${{ github.event.inputs.front_branch }}
path: front
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Replace Variables in values.yaml
env:
ECR_REPOSITORY: ${{ steps.login-ecr.outputs.registry }}/lago-front-staging
BRANCH: ${{ github.event.inputs.front_branch }}
run: envsubst < ./front/porter/values.yaml > ./front/porter/env_values.yaml
- name: Configure kubectl
run: echo "${{ secrets.KUBE_STAGING_CONFIG }}" | base64 -d > kubeconfig.yaml
- name: Get Helm deployment
id: helm_deployment
run: echo "::set-output name=deployment::$(helm --kubeconfig ./kubeconfig.yaml list -f ${{ github.event.inputs.front_branch }}-app -o=json | jq '.[0].name')"
- name: Delete Porter app
if: ${{ steps.helm_deployment.outputs.deployment != 'null' }}
run: |
helm --kubeconfig ./kubeconfig.yaml uninstall ${{ github.event.inputs.front_branch }}-app
- name: Create Porter app
uses: porter-dev/porter-cli-action@v0.1.0
with:
command: create web --app ${{ github.event.inputs.front_branch }}-app --source registry --values ./front/porter/env_values.yaml --image ${{ steps.login-ecr.outputs.registry }}/lago-front-staging:${{ github.event.inputs.front_branch }}
build-api-image:
name: Build API Image
runs-on: ubuntu-latest