Skip to content

fix(eso): copy tofu chart into values chart #439

fix(eso): copy tofu chart into values chart

fix(eso): copy tofu chart into values chart #439

Workflow file for this run

# Copyright The Linux Foundation and each contributor to LFX.
# SPDX-License-Identifier: MIT
---
name: Deploy Branch to Development
on:
pull_request:
types: [closed, labeled, unlabeled, synchronize]
permissions:
contents: read
packages: write
pull-requests: write
issues: write
id-token: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
# Only build a container if the PR is still open, it's labeled with
# 'deploy-preview' and does not come from a fork.
if: >
github.event.action != 'closed' &&
github.event.pull_request.state == 'open' &&
github.event.pull_request.head.repo.fork == false &&
contains(github.event.pull_request.labels.*.name, 'deploy-preview')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: OIDC Auth
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
role-to-assume: arn:aws:iam::788942260905:role/github-actions-deploy
aws-region: us-west-2
- name: Get LaunchDarkly client ID from AWS Secrets Manager
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
LAUNCHDARKLY, /cloudops/managed-secrets/launchdarkly/lfx_one/ld_client_id
- name: Set LaunchDarkly client ID environment variable
run: |
LAUNCHDARKLY_CLIENT_ID=$(echo "$LAUNCHDARKLY" | jq -r '.ld_client_id // empty')
if [ -z "$LAUNCHDARKLY_CLIENT_ID" ]; then
echo "❌ LaunchDarkly client ID not found in AWS Secrets Manager"
exit 1
fi
echo "LAUNCHDARKLY_CLIENT_ID=$LAUNCHDARKLY_CLIENT_ID" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=pr,prefix=ui-pr-
labels: |
org.opencontainers.image.title=LFX One UI
org.opencontainers.image.description=Linux Foundation LFX One UI application
org.opencontainers.image.vendor=The Linux Foundation
org.opencontainers.image.licenses=MIT
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/main/README.md
org.opencontainers.image.source=https://github.com/${{ github.repository }}
com.github.actions.run_id=${{ github.run_id }}
com.github.actions.run_number=${{ github.run_number }}
com.github.actions.workflow=${{ github.workflow }}
- name: Build and push Docker image
id: docker-build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_ENV=development
secret-envs: |
LAUNCHDARKLY_CLIENT_ID=LAUNCHDARKLY_CLIENT_ID
- name: Comment deployment URL on PR
uses: actions/github-script@v7
with:
script: |
const deploymentUrl = `https://ui-pr-${{ github.event.pull_request.number }}.dev.v2.cluster.linuxfound.info`;
const comment = `## 🚀 Deployment Status
Your branch has been deployed to: ${deploymentUrl}
**Deployment Details:**
- Environment: Development
- Namespace: ui-pr-${{ github.event.pull_request.number }}
- ArgoCD App: ui-pr-${{ github.event.pull_request.number }}
The deployment will be automatically removed when this PR is closed.`;
// Check if we already commented
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('## 🚀 Deployment Status')
);
if (botComment) {
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
cleanup-on-close:
if: >
(
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'deploy-preview')) ||
(github.event.action == 'unlabeled' && github.event.label.name == 'deploy-preview')
)
runs-on: ubuntu-latest
steps:
- name: Comment removal on PR
uses: actions/github-script@v7
with:
script: |
const comment = `## 🧹 Deployment Removed
The deployment for PR #${{ github.event.pull_request.number }} has been removed.`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});