Skip to content

Instantly share code, notes, and snippets.

@VishwaiOSDev
Created February 18, 2023 15:09
Show Gist options
  • Save VishwaiOSDev/5f708012bc807c58297f937bbfabad9d to your computer and use it in GitHub Desktop.
Save VishwaiOSDev/5f708012bc807c58297f937bbfabad9d to your computer and use it in GitHub Desktop.
This is a GitHub Actions workflow called "Deploy" that automatically deploys a Swift Vapor API to a remote server whenever code is pushed to the main branch (ignoring changes to markdown files).
name: Deploy
on:
push:
branches:
- main
paths-ignore:
- '**.md'
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
SSHKEY: ${{ secrets.SSHKEY }}
PORT: ${{ secrets.PORT }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
key: ${{ env.SSHKEY }}
port: ${{ env.PORT }}
script: |
whoami
cd /root/swift/IP2GeoVapor
git reset --hard
git pull --force
docker stop vaporAPI || true
docker rm vaporAPI || true
docker build . -t ip2geo-vapor
docker run -d --name vaporAPI -p 3001:3001 ip2geo-vapor
docker image prune -a --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment