Skip to content

directory creation for ssl certificate #83

directory creation for ssl certificate

directory creation for ssl certificate #83

Workflow file for this run

name: Publish and Deploy
on:
push:
branches:
- main
env:
SSH_USER: lhendrix
SSH_HOST: 51.68.188.78
REGISTRY: ghcr.io
IMAGE_NAME: battmoteam/battmogui:latest
WORKDIR: battmogui
jobs:
publish:
name: publish image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login
run: echo ${{ secrets.PAT }} | docker login ghcr.io -u lorenah84 --password-stdin
- name: Build
run: |
docker-compose -f docker-compose-deploy.yml build
- name: Publish
run: docker-compose -f docker-compose-deploy.yml push
deploy:
name: Deploy image
runs-on: ubuntu-latest
needs: publish
steps:
- name: Install SSH keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.ACTIONS_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Test SSH Connection
run: ssh -o StrictHostKeyChecking=no ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "echo SSH connection successful"
- name: Login to Registry
run: echo ${{ secrets.PAT }} | docker login ghcr.io -u lorenah84 --password-stdin
- name: Stop Running Containers
run: ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "cd ${{ env.WORKDIR }} && docker compose down"
- name: Pull and Run Containers
run: |
ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} "cd ${{ env.WORKDIR }} && \
docker compose -f docker-compose.yml pull && \
docker compose -f docker-compose.yml up -d"
- name: Cleanup
run: rm -rf ~/.ssh