forked from mathialm/secfit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Deploy to Development | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '**/*.js' | ||
| - '**/*.py' | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v1 | ||
|
|
||
| - name: Cache Docker layers | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: /tmp/.buildx-cache | ||
| key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-buildx- | ||
| - name: Build Docker image | ||
| run: | | ||
| docker build -t myapp:latest . | ||
| - name: Run Docker container | ||
| run: | | ||
| docker run -d -p 8080:80 myapp:latest | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: SSH to server and deploy | ||
| run: | | ||
| ssh -o StrictHostKeyChecking=no -i ${{ secrets.SSH_PRIVATE_KEY }} user@your-server-ip << 'EOF' | ||
| # Pull latest changes from GitHub (optional, if pulling directly) | ||
| cd /path/to/your/project | ||
| git pull origin main | ||
| docker build -t myapp:latest . | ||
| docker stop myapp || true | ||
| docker rm myapp || true | ||
| docker run -d -p 8080:80 --name myapp myapp:latest | ||
| EOF | ||
| env: | ||
| SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} |