github actions 调用宝塔webhooks 记录

github actions 调用宝塔webhooks 记录

如果不需要做其他任务直接调用webhooks可以直接在github 添加webhooks调用,位置在

github 的对应仓库的setting--webhooks(设置-webhooks)

 

 

如果需要先做其他的任务,那就在github actions添加webhooks

代码如下

# This is a basic workflow to help you get started with Actions

name: FTP部署

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@master

      # Runs a single command using the runners shell
      - name: 初始化环境
        run:  |
          sudo apt-get update
          sudo apt-get install -y git
          sudo apt-get install -y git-ftp

      # Runs a set of commands using the runners shell
      - name: 开始ftp同步
        run: |
          #替换你的ip或域名
          git config git-ftp.url ${{ secrets.FTP_IP }}
          #替换你的ftp账户
          git config git-ftp.user ${{ secrets.FTP_USER }}
          #替换你的ftp密码        
          git config git-ftp.password ${{ secrets.FTP_PASSWORD }}
          #--disable-epsv可选,因为我的服务器不支持epsv
          git ftp push --auto-init -vv --disable-epsv --changed-only -f
        #调用宝塔那边的webhook重启python运行环境,让整个项目生效。
      - name: 调用webhook
        uses: distributhor/workflow-webhook@v1
        env:
          webhook_url: ${{ secrets.WEBHOOK_URL }}
          webhook_secret: ${{ secrets.WEBHOOK_SECRET }}

这段代码是github actions 先安装git 和git-ftp,然后git 检出代码,之后git-ftp上传到服务器,最后调用webhooks

github actions代码也可以参考  https://www.rxx0.com/software/github_actions_shi_ling_le.html

https://github.com/SamKirkland/FTP-Deploy-Action/issues/195

 

版权声明:
作者:xinyu2ru
链接:https://www.rxx0.com/software/github_actions_diao_yong_bao_ta_webhooks_ji_lu.html
来源:RUBLOG-分享我的生活
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>