1. # CI名称,默认为文件名
    2. name: Node.js CI
    3. # 监听 push事件 对应分支 master
    4. on:
    5. push:
    6. branches: [master]
    7. jobs:
    8. build:
    9. # 运行所需要的虚拟机环境 - 必填
    10. runs-on: ubuntu-18.04
    11. strategy:
    12. matrix:
    13. node-version: [14.x]
    14. # 每个 - 代表一个单独的步骤
    15. # name 步骤名
    16. # uses 使用的工具
    17. # with 对应uses工具版本
    18. # run 脚本命令
    19. steps:
    20. - uses: actions/checkout@v2
    21. - name: Use Node.js ${{ matrix.node-version }}
    22. uses: actions/setup-node@v1
    23. with:
    24. node-version: ${{ matrix.node-version }}
    25. - name: Install dependencies and Build for production used by Yarn
    26. run: yarn install && yarn build
    27. env:
    28. CI: true
    29. # https://github.com/easingthemes/ssh-deploy
    30. - name: Deploy to Aliyun
    31. uses: easingthemes/ssh-deploy@v2.1.1
    32. env:
    33. SSH_PRIVATE_KEY: ${{ secrets.BLOG_ALIYUN_SSH }}
    34. ARGS: '-avzr --delete'
    35. SOURCE: 'blog/'
    36. REMOTE_HOST: ${{ secrets.BLOG_ALIYUN_HOST }}
    37. REMOTE_USER: ${{ secrets.BLOG_ALIYUN_USER }}
    38. TARGET: ${{ secrets.BLOG_ALIYUN_PATH }}
    • 服务器上是用 docker 部署的 nginx
    • easingthemes/ssh-deploy是由开发者们贡献的action脚本,可以在官方市场自行选择并查阅配置
    • ssh公钥等密钥不能显式使用,应于项目仓库Setting的Secrets中配置,采用以上脚本形式获取