Create deploy-dev.yml #1
This file contains 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: Deploy to Development | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Build Docker image | |
| run: | | |
| # Build the Docker image and tag it with "latest" | |
| docker build -t myapp:latest . | |
| - name: Stop and remove existing container | |
| run: | | |
| # If there's an existing container, stop and remove it. | |
| docker rm -f myapp_container || true | |
| - name: Run Docker container | |
| run: | | |
| # Run the new container in detached mode, mapping port 80 | |
| docker run -d --name myapp_container -p 80:80 myapp:latest |