Home animations #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: code-npm-deploy | |
on: | |
pull_request: | |
types: [closed] | |
branches: ["main", "main-*"] | |
paths: ["code/**", ".github/workflows/code**"] | |
workflow_dispatch: | |
inputs: | |
BASELINE: | |
description: "Baseline branch" | |
required: true | |
default: "main" | |
env: | |
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | |
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
AZURE_ACR_USERNAME: ${{ secrets.AZURE_ACR_USERNAME }} | |
AZURE_ACR_PASSWORD: ${{ secrets.AZURE_ACR_PASSWORD }} | |
AZURE_ACR_NAME: "weavejs" | |
AZURE_RESOURCE_GROUP: "weavejs-test" | |
AZURE_CONTAINER_ENVIRONMENT_NAME: "managedEnvironment-weavejstest-aad6" | |
AZURE_CONTAINER_NAME: "weavejs-frontend" | |
AZURE_CONTAINER_NAME_BACKEND: "weavejs-backend" | |
AZURE_IDENTITY_ID: ${{ secrets.AZURE_IDENTITY_ID }} | |
NEXT_PUBLIC_API_ENDPOINT: ${{ vars.NEXT_PUBLIC_API_ENDPOINT }} | |
NEXT_PUBLIC_API_ENDPOINT_HUB_NAME: ${{ vars.NEXT_PUBLIC_API_ENDPOINT_HUB_NAME }} | |
BACKEND_ENDPOINT: "http://weavejs-backend" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
deploy: | |
name: Deploy to Container Apps | |
runs-on: ubuntu-24.04 | |
environment: production | |
steps: | |
- name: Checkout merge commit | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Create .env.production file | |
working-directory: code | |
run: | | |
touch .env.production | |
echo NEXT_PUBLIC_API_ENDPOINT=${{ env.NEXT_PUBLIC_API_ENDPOINT }} >> .env.production | |
echo NEXT_PUBLIC_API_ENDPOINT_HUB_NAME=${{ env.NEXT_PUBLIC_API_ENDPOINT_HUB_NAME }} >> .env.production | |
echo BACKEND_ENDPOINT=${{ env.BACKEND_ENDPOINT }} >> .env.production | |
cat .env.production | |
- name: ACR Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.AZURE_ACR_NAME }}.azurecr.io | |
username: ${{ env.AZURE_ACR_USERNAME }} | |
password: ${{ env.AZURE_ACR_PASSWORD }} | |
- name: Build image and push it to ACR | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
platforms: linux/amd64 | |
context: code | |
tags: ${{ env.AZURE_ACR_NAME }}.azurecr.io/${{ env.AZURE_CONTAINER_NAME }}:${{ github.sha }} | |
file: code/Dockerfile | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ env.AZURE_CLIENT_ID }} | |
tenant-id: ${{ env.AZURE_TENANT_ID }} | |
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }} | |
- name: Deploy | |
uses: azure/cli@v2 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
az containerapp create \ | |
--name $AZURE_CONTAINER_NAME \ | |
--resource-group $AZURE_RESOURCE_GROUP \ | |
--environment $AZURE_CONTAINER_ENVIRONMENT_NAME \ | |
--image $AZURE_ACR_NAME.azurecr.io/$AZURE_CONTAINER_NAME:${{ github.sha }} \ | |
--target-port 8080 \ | |
--ingress external \ | |
--registry-server $AZURE_ACR_NAME.azurecr.io \ | |
--user-assigned "$AZURE_IDENTITY_ID" \ | |
--registry-identity "$AZURE_IDENTITY_ID" \ | |
--min-replicas 1 \ | |
--max-replicas 2 \ | |
--scale-rule-name http-rule \ | |
--scale-rule-type http \ | |
--scale-rule-http-concurrency 10 \ | |
--query properties.configuration.ingress.fqdn |