[英]How to run bat file on windows server using GitHub Actions?
I find many solutions for Linux but how can I run a bat file on a windows server using SSH and GitHub Actions?我找到了许多 Linux 的解决方案,但如何使用 SSH 和 GitHub 操作在 windows 服务器上运行 bat 文件?
If you want to SSH into a windows server using Github action then you can utilize SSH Remote Commands .如果您想使用 Github 操作将 SSH 转换为 windows 服务器,那么您可以使用SSH 远程命令。 Once successfully logged in you can run the command
登录成功后可以运行命令
Example from SSH Remote Commands来自SSH 远程命令的示例
name: remote ssh command
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: whoami
A sample GitHub Action will be like this示例 GitHub 操作将是这样的
name: SSH into windows server and run bat file
on:
workflow_dispatch:
jobs:
ssh:
runs-on: ubuntu-latest
steps:
- name: SSH into windows server and run bat file
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd C:\Users\user\Documents\GitHub\test
dir
test.bat
# Check if the bat file ran successfully
check:
runs-on: ubuntu-latest
needs: ssh
steps:
- name: Check if the bat file ran successfully
if: ${{ needs.ssh.outputs.exitcode == 0 }}
run: |
echo "Check if the bat file ran successfully"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.