Skip to content

feat: updated workflow for ci/cd #6

feat: updated workflow for ci/cd

feat: updated workflow for ci/cd #6

Workflow file for this run

name: Build & Push Docker Image
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/mohith1612/invoicely:latest
ghcr.io/mohith1612/invoicely:${{ github.sha }}
- name: Deploy to VM
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
export IMAGE_TAG=${{ github.sha }}
echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u Mohith1612 --password-stdin
cd /opt/invoice
docker compose pull web
docker compose up -d web
docker image prune -af --filter "until=72h"