ex24 [deploy to dockerhub] #81
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 Dev Server | |
on: | |
push: | |
branches: | |
- jh-dev | |
paths-ignore: | |
- '**.github/workflows/**' # Ignore changes to workflow files | |
if: "contains(github.event.head_commit.message, '[deploy to dev]')" # Adjust trigger condition as needed | |
jobs: | |
deploy-to-dev-server: | |
if: "contains(github.event.head_commit.message, '[deploy to dev]')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Log in to Dev Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DEV_SERVER_HOST }} | |
username: ${{ secrets.DEV_SERVER_USERNAME }} | |
key: ${{ secrets.DEV_SERVER_SSH_PRIVATE_KEY }} | |
- name: Copy deploy.sh to Dev Server | |
run: | | |
scp deploy.sh ${{ secrets.DEV_SERVER_USERNAME }}@${{ secrets.DEV_SERVER_HOST }}:~/deploy.sh | |
- name: Execute deploy.sh on Dev Server | |
run: | | |
ssh ${{ secrets.DEV_SERVER_USERNAME }}@${{ secrets.DEV_SERVER_HOST }} \ | |
"chmod +x ~/deploy.sh && ~/deploy.sh" |