updated resources to point to production url #65
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: Docker Build and Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
submodules: true # Ensure submodules are checked out | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log into Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker Image | |
run: | | |
docker build --file Dockerfile --tag mikeintosh/mikeintosh-phpdashboard-app:latest . | |
- name: Push Docker Image | |
run: | | |
docker push mikeintosh/mikeintosh-phpdashboard-app:latest | |
deploy: | |
name: Deploy Docker Container | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
submodules: true # Ensure submodules are checked out | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Log into Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
- name: Cleanup previous containers | |
run: | | |
docker-compose down || true | |
docker system prune -f | |
- name: List running containers | |
run: docker ps -a | |
- name: Deploy Docker Container | |
run: | | |
docker-compose pull && docker-compose up -d | |
# Optional: Cleanup unused images and containers | |
- name: Cleanup Docker | |
run: | | |
docker system prune -f | |
# Uncomment the following step to deploy automatically to your server | |
# - name: SSH into Server and Pull Docker Image | |
# uses: appleboy/ssh-action@master | |
# with: | |
# host: ${{ secrets.SERVER_HOST }} | |
# username: ${{ secrets.SERVER_USERNAME }} | |
# key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }} | |
# script: | | |
# cd /path/to/project | |
# docker-compose pull | |
# docker-compose up -d |