Skip to content

Revert "remove fa import" #89

Revert "remove fa import"

Revert "remove fa import" #89

Workflow file for this run

name: Deploy and Release
on:
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'main'
jobs:
deploy_and_release:
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || 'main' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/loftwah/linkarooie:${{ github.event.inputs.branch || 'latest' }}
- name: Deploy to droplet
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DROPLET_IP }}
username: root
key: ${{ secrets.DROPLET_SSH_PRIVATE_KEY }}
script: |
echo "${{ secrets.GH_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# Stop the running containers
docker compose -f docker-compose.prod.yml down
# Pull the latest images
docker compose -f docker-compose.prod.yml pull
# Run database migrations (if necessary)
docker compose -f docker-compose.prod.yml run --rm app rails db:migrate
# Start the new containers
docker compose -f docker-compose.prod.yml up -d
# Remove unused images and containers
docker system prune -af
- name: Get current datetime
id: date
run: echo "DATETIME=$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
- name: Create Release
uses: elgohr/Github-Release-Action@v5
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
title: Release ${{ steps.date.outputs.DATETIME }}
tag: release-${{ steps.date.outputs.DATETIME }}