CI: Auto-deploy to VPS when PR is merged into main #61

Closed
opened 2026-03-08 10:19:11 +00:00 by Bartender · 1 comment
Owner

Goal

Create a workflow that automatically deploys Cozy-Den to the production VPS when a pull request is merged into the main branch.

Context

The repository already contains CI workflows and the VPS has a runner installed. The goal is to use the runner to perform deployment automatically after a successful merge.

Desired behavior

When a pull request is merged into main:

  1. The workflow triggers automatically.
  2. The repository is pulled on the VPS (or code is checked out by the runner).
  3. The site is built using the existing Astro setup.
  4. The production service/container is restarted.

Possible implementation

Example approach:

  • Trigger:
on:
  push:
    branches:
      - main
  • Steps could include:
  1. Checkout repository
  2. Install dependencies
  3. Build Astro project
  4. Run deployment script (docker compose / restart service)

Example step idea:

jobs:
  deploy:
    runs-on: self-hosted

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install dependencies
        run: npm ci

      - name: Build site
        run: npm run build

      - name: Deploy
        run: docker compose up -d --build

Things to decide

  • Whether deployment should:
    • rebuild docker image
    • pull latest and restart container
    • rsync built static files

Acceptance criteria

  • Merging a PR into main triggers the workflow.
  • The runner on the VPS performs the deployment.
  • The live site updates automatically without manual intervention.

This will allow Cozy-Den to be deployed via PR workflow instead of manual deployment.

## Goal Create a workflow that automatically deploys Cozy-Den to the production VPS when a pull request is merged into the `main` branch. ## Context The repository already contains CI workflows and the VPS has a runner installed. The goal is to use the runner to perform deployment automatically after a successful merge. ## Desired behavior When a pull request is merged into `main`: 1. The workflow triggers automatically. 2. The repository is pulled on the VPS (or code is checked out by the runner). 3. The site is built using the existing Astro setup. 4. The production service/container is restarted. ## Possible implementation Example approach: - Trigger: ```yaml on: push: branches: - main ``` - Steps could include: 1. Checkout repository 2. Install dependencies 3. Build Astro project 4. Run deployment script (docker compose / restart service) Example step idea: ```yaml jobs: deploy: runs-on: self-hosted steps: - name: Checkout uses: actions/checkout@v4 - name: Install dependencies run: npm ci - name: Build site run: npm run build - name: Deploy run: docker compose up -d --build ``` ## Things to decide - Whether deployment should: - rebuild docker image - pull latest and restart container - rsync built static files ## Acceptance criteria - Merging a PR into `main` triggers the workflow. - The runner on the VPS performs the deployment. - The live site updates automatically without manual intervention. --- This will allow Cozy-Den to be deployed via PR workflow instead of manual deployment.
Owner

not for now, nhe

not for now, nhe
Latte closed this issue 2026-03-08 16:24:13 +00:00
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Hiddenden/Cozy-Den#61