Skip to content

fix: pick up VITE_API_URL from .env for local astro dev (#25) #16

fix: pick up VITE_API_URL from .env for local astro dev (#25)

fix: pick up VITE_API_URL from .env for local astro dev (#25) #16

Workflow file for this run

name: Deploy Dev
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
backend: ${{ github.event_name == 'workflow_dispatch' || steps.filter.outputs.backend == 'true' }}
frontend: ${{ github.event_name == 'workflow_dispatch' || steps.filter.outputs.frontend == 'true' }}
steps:
- uses: actions/checkout@v5
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
docker-backend:
runs-on: ubuntu-latest
needs: [changes]
if: needs.changes.outputs.backend == 'true'
steps:
- uses: actions/checkout@v5
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: backend/Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}/backend:${{ github.sha }}
ghcr.io/${{ github.repository }}/backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
docker-frontend:
runs-on: ubuntu-latest
needs: [changes]
if: needs.changes.outputs.frontend == 'true'
steps:
- uses: actions/checkout@v5
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: frontend/Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}/frontend:${{ github.sha }}
ghcr.io/${{ github.repository }}/frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
runs-on: ubuntu-latest
needs: [changes, docker-backend, docker-frontend]
if: |
!cancelled() &&
(needs.docker-backend.result == 'success' || needs.docker-frontend.result == 'success')
steps:
- uses: actions/checkout@v5
with:
repository: breithorn-poc/rob-poc
token: ${{ secrets.ARGO_PAT }}
path: argocd
- name: Update backend image tag
if: needs.changes.outputs.backend == 'true'
run: |
sed -i "s|image: ghcr.io/swiss-ai/serving-api/backend:.*|image: ghcr.io/swiss-ai/serving-api/backend:${{ github.sha }}|" argocd/serving-api/dev/backend-deployment.yaml
- name: Update frontend image tag
if: needs.changes.outputs.frontend == 'true'
run: |
sed -i "s|image: ghcr.io/swiss-ai/serving-api/frontend:.*|image: ghcr.io/swiss-ai/serving-api/frontend:${{ github.sha }}|" argocd/serving-api/dev/frontend-deployment.yaml
- name: Commit and push
run: |
cd argocd
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add serving-api/dev/
git diff --staged --quiet && echo "No changes to deploy" || (git commit -m "deploy serving-api ${{ github.sha }}" && git push)
notify:
name: Slack Notification
runs-on: ubuntu-latest
needs: [changes, docker-backend, docker-frontend, deploy]
if: always()
steps:
- name: Notify Slack
uses: slackapi/slack-github-action@v2
with:
webhook-type: incoming-webhook
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
payload: |
{
"text": "${{ github.repository }} Deploy Dev — ${{ contains(needs.*.result, 'failure') && 'FAILED' || 'deployed' }}\nCommit: ${{ github.sha }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>"
}