Skip to content

Commit

Permalink
deploy with azure cli instead
Browse files Browse the repository at this point in the history
  • Loading branch information
havardthom committed Sep 19, 2024
1 parent 19cedde commit 6f0f228
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
49 changes: 21 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Trigger auto deployment

# When this action will be executed
on:
# Uncomment the code below for automatically trigger the workflow when detected changes in the main branch
push:
branches: [main]

Expand All @@ -15,43 +13,38 @@ permissions:

jobs:
build-and-deploy:
runs-on: [sb1u]
runs-on: ubuntu-latest

steps:
- name: Checkout to the branch
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v4
- name: Docker Login
uses: docker/#-action@v3
with:
node-version: "20.x"

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Azure CLI
run: pip install azure-cli

# - name: Set up Postgresql with prisma
# run: |
# DATABASE_URL=${{secrets.DATABASE_URL}} npx prisma generate
# DATABASE_URL=${{secrets.DATABASE_URL}} npx prisma migrate deploy
registry: ${{ secrets.ACR_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Azure Login
uses: azure/#@v1
uses: azure/#@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}


- name: Build and push container image to registry
uses: azure/container-apps-deploy-action@v2
- name: Build and Push to ACR
uses: docker/build-push-action@v2
with:
appSourcePath: ${{ github.workspace }}
registryUrl: sbukrokeloneacr.azurecr.io
registryUsername: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
registryPassword: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
imageToBuild: sbukrokeloneacr.azurecr.io/krokelo:${{ github.sha }}
dockerfilePath: Dockerfile
push: true
tags: ${{ secrets.ACR_URL }}/krokelo:${{ github.sha }}
file: Dockerfile

- name: Redeploy Azure Container App
run: |
az containerapp revision copy \
--name krokelo \
--resource-group sbu-public-krokelo-nww-nea-rg \
--cpu 1 \
--memory 2.0 \
--image ${{ secrets.ACR_URL }}/krokelo:${{ github.sha }}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ RUN npx prisma generate
ADD . .
RUN npm run build

# Run migrations
ARG DATABASE_URL
RUN npm run deploy:db

# Finally, build the production image with minimal footprint
FROM base

Expand Down

0 comments on commit 6f0f228

Please # to comment.