1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00
Octobot/.github/workflows/build-push.yml
Octol1ttle 84dc248038
Add Dockerfile and compose.yaml (#335)
This PR adds Dockerfile, to run Octobot within a Docker container, and
compose.yaml, to run the Octobot container along with any services that
the user may require.

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
Co-authored-by: mctaylors <cantsendmails@mctaylors.ru>
2024-10-27 22:31:04 +05:00

78 lines
2.2 KiB
YAML

name: "Publish and deploy"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ "master" ]
jobs:
upload-image:
name: Upload Octobot Docker image
runs-on: ubuntu-latest
permissions:
packages: write
environment: production
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/${{vars.NAMESPACE}}/${{vars.IMAGE_NAME}}:latest
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
PUBLISH_OPTIONS=${{vars.PUBLISH_OPTIONS}}
update-production:
name: Update Octobot on production
runs-on: ubuntu-latest
environment: production
needs: upload-image
steps:
- name: Setup SSH key
run: |
install -m 600 -D /dev/null ~/.ssh/id_ed25519
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts
shell: bash {0}
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
SSH_HOST: ${{secrets.SSH_HOST}}
- name: Stop currently running instance
run: |
ssh $SSH_USER@$SSH_HOST $STOP_COMMAND
shell: bash {0}
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
STOP_COMMAND: ${{vars.STOP_COMMAND}}
- name: Update Docker image
run: |
ssh $SSH_USER@$SSH_HOST docker pull ghcr.io/$NAMESPACE/$IMAGE_NAME:latest
shell: bash {0}
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
NAMESPACE: ${{vars.NAMESPACE}}
IMAGE_NAME: ${{vars.IMAGE_NAME}}
- name: Start new instance
run: |
ssh $SSH_USER@$SSH_HOST $START_COMMAND
shell: bash {0}
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
START_COMMAND: ${{vars.START_COMMAND}}