All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 4s
41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
name: build-and-deploy
|
||
|
||
on:
|
||
push:
|
||
branches: [ main, master ]
|
||
|
||
jobs:
|
||
build-and-deploy:
|
||
runs-on: docker
|
||
env:
|
||
REG: ${{ vars.REGISTRY_URL }}
|
||
REPO_OWNER: ${{ github.repository_owner }}
|
||
APP_NAME: ${{ vars.APP_NAME }}
|
||
APP_DOMAIN: ${{ vars.APP_DOMAIN }}
|
||
NUXT_PUBLIC_APP_URL: ${{ vars.NUXT_PUBLIC_APP_URL }}
|
||
steps:
|
||
- uses: actions/checkout@v3
|
||
|
||
- name: Build, push and deploy
|
||
run: |
|
||
# Login to registry
|
||
docker login $REG -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }}
|
||
|
||
# Build and push
|
||
echo "🔨 Building image..."
|
||
cd nuxt4
|
||
docker build -t $REG/$REPO_OWNER/$APP_NAME:${{ github.sha }} -t $REG/$REPO_OWNER/$APP_NAME:latest .
|
||
echo "📤 Pushing images..."
|
||
docker push $REG/$REPO_OWNER/$APP_NAME:${{ github.sha }}
|
||
docker push $REG/$REPO_OWNER/$APP_NAME:latest
|
||
|
||
# Deploy
|
||
cd ..
|
||
echo "ℹ️ Deploying $APP_NAME"
|
||
echo " Domain: $APP_DOMAIN"
|
||
echo " Image: $REG/$REPO_OWNER/$APP_NAME:latest"
|
||
|
||
docker compose pull
|
||
docker compose --project-name $APP_NAME down
|
||
docker compose --project-name $APP_NAME up -d --remove-orphans --wait
|