Deploy workflow (#500)

## Description:

Adds a github workflow to deploy changes to staging or production.

## Steps to enable this workflow

1. Create two github environments at
https://github.com/openfrontio/OpenFrontIO/settings/environments.
- They have to be named `production` and `staging`, unless you modify
the yaml.
2. In each github environment, create two two variables:
    -  `DOCKERHUB_REPO`
    - `DOCKERHUB_USERNAME`
3. In each github environment, create four secrets:
    - `DOCKERHUB_TOKEN`
    - `SERVER_HOST`
    - `SERVER_USERNAME`
    - `SSH_PRIVATE_KEY`

Fixes #504 

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

fake.neo

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
Scott Anderson
2025-04-12 21:36:05 -04:00
committed by GitHub
parent adb29035c0
commit b6ec41f350
+38
View File
@@ -0,0 +1,38 @@
name: Deploy to Remote
on:
workflow_dispatch:
inputs:
target_environment:
description: "Deployment Environment"
required: true
default: "staging"
type: choice
options:
- production
- staging
jobs:
deploy:
name: Deploy to ${{ inputs.target_environment }}
runs-on: ubuntu-latest
environment: ${{ inputs.target_environment }}
steps:
- uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
cat >.env <<EOF
SERVER_HOST_STAGING=${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
DOCKER_REPO_STAGING=${{ vars.DOCKERHUB_REPO }}
DOCKER_USERNAME=${{ vars.DOCKERHUB_USERNAME }}
EOF
./deploy.sh ${{ inputs.target_environment }}