From b6ec41f3505ffdbd4e866fb921dccf6ce5e55a03 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 12 Apr 2025 21:36:05 -0400 Subject: [PATCH] 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> --- .github/workflows/deploy.yml | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..847ce0fa9 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 <