Skip to content

Update production.yml #14

Update production.yml

Update production.yml #14

Workflow file for this run

name: Production
on:
push:
branches: "production"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/production_disappear:latest
- name: Connect via SSH and restart container
uses: appleboy/ssh-action@v0.1.9
with:
host: ${{ secrets.PD_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PD_KEY }}
port: ${{ secrets.PORT }}
script: |
sudo docker stop production_container || true
sudo docker rm production_container || true
sudo docker run --name production_container -p 80:8000 -d \
-e DBHOST=${{ secrets.PD_DBHOST }} \
-e DBPORT=${{ secrets.PD_DBPORT }} \
-e DBUSER=${{ secrets.DBUSER }} \
-e DBNAME=${{ secrets.DBNAME }} \
-e DBPASS=${{ secrets.PD_DBPASS }} \
${{ secrets.DOCKERHUB_USERNAME }}/production_disappear:latest