release
This commit is contained in:
parent
0460e5ebbc
commit
2427019beb
124
.github/workflows/cicd.yaml
vendored
Normal file
124
.github/workflows/cicd.yaml
vendored
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Frontend CI/CD Pipeline
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ${{ vars.REGISTRY || 'dg0200cr.azurecr.io' }}
|
||||||
|
IMAGE_ORG: ${{ vars.IMAGE_ORG || 'lifesub' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build application
|
||||||
|
run: npm run build
|
||||||
|
env:
|
||||||
|
CI: false
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: build-artifacts
|
||||||
|
path: build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
image_tag: ${{ steps.set-tag.outputs.tag }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download build artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: build-artifacts
|
||||||
|
path: build
|
||||||
|
|
||||||
|
- name: Set timestamp for image tag
|
||||||
|
id: set-tag
|
||||||
|
run: echo "tag=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Login to Azure Container Registry
|
||||||
|
uses: azure/docker-login@v1
|
||||||
|
with:
|
||||||
|
login-server: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.ACR_USERNAME }}
|
||||||
|
password: ${{ secrets.ACR_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--build-arg PROJECT_FOLDER="." \
|
||||||
|
--build-arg REACT_APP_MEMBER_URL="${{ secrets.REACT_APP_MEMBER_URL }}" \
|
||||||
|
--build-arg REACT_APP_MYSUB_URL="${{ secrets.REACT_APP_MYSUB_URL }}" \
|
||||||
|
--build-arg REACT_APP_RECOMMEND_URL="${{ secrets.REACT_APP_RECOMMEND_URL }}" \
|
||||||
|
--build-arg BUILD_FOLDER="deployment" \
|
||||||
|
--build-arg EXPORT_PORT="18080" \
|
||||||
|
-f deployment/Dockerfile-lifesub-web \
|
||||||
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE_ORG }}/lifesub-web:${{ steps.set-tag.outputs.tag }} .
|
||||||
|
|
||||||
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_ORG }}/lifesub-web:${{ steps.set-tag.outputs.tag }}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Azure login
|
||||||
|
uses: azure/login@v1
|
||||||
|
with:
|
||||||
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
||||||
|
|
||||||
|
- name: Set AKS context
|
||||||
|
uses: azure/aks-set-context@v3
|
||||||
|
with:
|
||||||
|
resource-group: ictcoe-edu
|
||||||
|
cluster-name: dg0200-aks
|
||||||
|
|
||||||
|
- name: Load environment variables
|
||||||
|
run: source deployment/deploy_env_vars-front
|
||||||
|
|
||||||
|
- name: Generate manifest
|
||||||
|
run: |
|
||||||
|
export namespace=dg0200-lifesub-web-ns
|
||||||
|
export lifesub_web_image_path=${{ env.REGISTRY }}/${{ env.IMAGE_ORG }}/lifesub-web:${{ needs.release.outputs.image_tag }}
|
||||||
|
export replicas=1
|
||||||
|
export export_port=18080
|
||||||
|
export resources_requests_cpu=256m
|
||||||
|
export resources_requests_memory=256Mi
|
||||||
|
export resources_limits_cpu=1024m
|
||||||
|
export resources_limits_memory=1024Mi
|
||||||
|
|
||||||
|
envsubst < deployment/deploy.yaml.template-front > deployment/deploy.yaml
|
||||||
|
cat deployment/deploy.yaml
|
||||||
|
|
||||||
|
- name: Deploy to AKS
|
||||||
|
run: |
|
||||||
|
kubectl apply -f deployment/deploy.yaml
|
||||||
|
|
||||||
|
echo "Waiting for deployment to be ready..."
|
||||||
|
kubectl -n dg0200-lifesub-web-ns wait --for=condition=available deployment/lifesub-web --timeout=300s
|
||||||
|
|
||||||
|
echo "Waiting for service external IP..."
|
||||||
|
while [[ -z $(kubectl -n dg0200-lifesub-web-ns get svc lifesub-web -o jsonpath='{.status.loadBalancer.ingress[0].ip}') ]]; do
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
echo "Service external IP: $(kubectl -n dg0200-lifesub-web-ns get svc lifesub-web -o jsonpath='{.status.loadBalancer.ingress[0].ip}')"
|
||||||
Loading…
x
Reference in New Issue
Block a user