feat(ci/cd): add Docker deployment
This commit is contained in:
parent
018f90fc2d
commit
8c451433e7
40
.github/workflows/docker-image.yml
vendored
40
.github/workflows/docker-image.yml
vendored
@ -1,18 +1,42 @@
|
|||||||
name: Docker Image CI
|
name: Docker Image build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: ["main"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: ["main"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
name: Build Docker image and push to repositories
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout code
|
||||||
- name: Build the Docker image
|
uses: actions/checkout@v4
|
||||||
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
|
|
||||||
|
- name: login to hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: alexohneander/sim-free:latest
|
||||||
|
|
||||||
|
- name: deploying
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SSH_HOST }}
|
||||||
|
username: ${{ secrets.SSH_USER }}
|
||||||
|
password: ${{ secrets.SSH_KEY }}
|
||||||
|
port: ${{ secrets.SSH_PORT }}
|
||||||
|
script: |
|
||||||
|
docker image pull alexohneander/sim-free:latest
|
||||||
|
docker container stop sim-free
|
||||||
|
docker container rm sim-free
|
||||||
|
docker container run -d --name sim-free -p 8000:8000 alexohneander/sim-free:latest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user