new update all #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |