add github actions and Dockerfile for deployment #3
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 | ||
on: | ||
push: | ||
branches: [main] | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/#-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP_NAME }}:latest | ||
- name: Deploy to server (replace with your deployment steps) | ||
uses: ssh-actions/deploy@v2 | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
user: ${{ secrets.SERVER_USERNAME }} | ||
privateKey: ${{ secrets.SERVER_SSH_KEY }} | ||
commands: | ||
- docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP_NAME }}:latest | ||
Check failure on line 32 in .github/workflows/deploy.yml GitHub Actions / DeployInvalid workflow file
|
||
- docker stop your-app-container || true | ||
- docker rm your-app-container || true | ||
- docker run -d -p 8080:8080 --name your-app-container ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_APP_NAME }}:latest |