Skip to content

new update all

new update all #14

name: Build, Push, and Deploy Docker Image
on:
push:
branches:
- main
jobs:
build-push-deploy:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to DockerHub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/python-flas-ci:latest .
- name: Push Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/python-flas-ci:latest
- name: Stop and remove existing container (if any)
run: docker rm -f python-flas-ci || true
- name: Pull updated image
run: docker pull ${{ secrets.DOCKER_USERNAME }}/python-flas-ci:latest
- name: Run updated container
run: |
docker run -d \
--name python-flas-ci \
-p 8080:8080 \
${{ secrets.DOCKER_USERNAME }}/python-flas-ci:latest