mirror of
https://github.com/getlago/lago.git
synced 2025-07-04 07:18:04 +07:00
cd: add front deployment
This commit is contained in:
77
.github/workflows/deploy-preview.yml
vendored
77
.github/workflows/deploy-preview.yml
vendored
@ -11,17 +11,82 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
default: 'main'
|
default: 'main'
|
||||||
jobs:
|
jobs:
|
||||||
deploy-front:
|
build-front-image:
|
||||||
name: Deploy Front
|
name: Deploy Front
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Front Repository Dispatch
|
- name: Checkout Front
|
||||||
uses: peter-evans/repository-dispatch@v1
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.REPO_ACCESS_TOKEN }}
|
|
||||||
repository: getlago/lago-front
|
repository: getlago/lago-front
|
||||||
event-type: deploy-preview
|
ref: ${{ github.event.inputs.front_branch }}
|
||||||
client-payload: '{ "branch": "${{ 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:
|
build-api-image:
|
||||||
name: Build API Image
|
name: Build API Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
Reference in New Issue
Block a user