feat: added environments and launch functionality to projects #154
This file contains 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
# The name of the deployment | |
name: Deploy preview environments on PR | |
# When this action will be executed | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- main | |
paths: | |
- 'web/dashboard/**' | |
- '.github/workflows/dashboard-preview.yml' | |
workflow_dispatch: | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
jobs: | |
deploy_preview: | |
environment: playground | |
name: Deploy preview environment to Container App | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Log in to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Create Neon Branch | |
id: create-branch | |
uses: neondatabase/create-branch-action@v4 | |
with: | |
project_id: ${{ env.NEON_PROJECT_ID }} | |
branch_name: preview/pr-${{ github.event.number }} | |
username: ${{ env.NEON_DATABASE_USERNAME }} | |
api_key: ${{ secrets.NEON_API_KEY }} | |
- name: Setup environment | |
run: | | |
echo "${{ secrets.AZURE_BLOB_STORAGE_ACCOUNT }}" >> ./web/dashboard/.env | |
echo "${{ secrets.AZURE_BLOB_STORAGE_SECRET }}" >> ./web/dashboard/.env | |
echo "${{ secrets.NEXT_AUTH_SECRET }}" >> ./web/dashboard/.env | |
echo "DRIZZLE_DATABASE_TYPE=neon" >> ./web/dashboard/.env | |
echo "DRIZZLE_DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require" >> ./web/dashboard/.env | |
cd ./web/dashboard | |
corepack enable pnpm | |
pnpm i --frozen-lockfile | |
pnpm --filter "@ethereal-nexus/dashboard" run generate | |
- name: Deploy Container App | |
uses: azure/container-apps-deploy-action@v1 | |
with: | |
containerAppName: ethereal-nexus-app-${{ github.event.number }} | |
appSourcePath: ${{ github.workspace }} | |
dockerfilePath: web/dashboard/Dockerfile | |
acrName: etherealnexus | |
acrUsername: ${{ secrets.REGISTRY_USERNAME }} | |
acrPassword: ${{ secrets.REGISTRY_PASSWORD }} | |
resourceGroup: RG-Ethereal-Nexus | |
location: westeurope | |
targetPort: 3000 | |
- name: Update Environment Variables | |
run: | | |
fqdn=$(az containerapp ingress show -g RG-Ethereal-Nexus -n ethereal-nexus-app-$PR_NUMBER | jq -r '.fqdn') | |
az containerapp update -g RG-Ethereal-Nexus -n ethereal-nexus-app-$PR_NUMBER --set-env-vars NEXTAUTH_URL=https://${fqdn} |