收集各种用法的 Github Action

16Reverie
2025-04-15
点 赞
2
热 度
79
评 论
0

文章摘要

智阅GPT

语言类

执行 JavaScript 代码

名称及示例action/github-script

    - name: Install axios
      run: npm install axios@1.8.4
    - name: Check Detail Data
      id: handel-json
      uses: actions/github-script@v7
      with:
        result-encoding: string
        script: |
          const axios = require('axios');
          const response = await axios.get(url, { timeout: 5000 });
          ...data...

仓库地址:https://github.com/actions/github-script

安装 Python 运行环境

名称及示例:actions/setup-python

    - uses: actions/setup-python@v5
      with:
        python-version: '3.13' 
    - run: python my_script.py  

仓库地址:https://github.com/actions/setup-python

安装 Node.js

名称及示例:setup-node

     - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'

      - name: Install dependencies
        run: npm install

      - name: Run Node.js script
        run: node index.js    

仓库地址:https://github.com/actions/setup-node

常用工具类

仓库提交

名称及示例:EndBug/add-and-commit@v9

    - name: Git Add and Commit
      uses: EndBug/add-and-commit@v9
      with:
        message: 'chore(data): update neodb data'
        committer_name: 'github-actions[bot]'
        committer_email: 'github-actions[bot]@users.noreply.github.com'
        add: |
          './data'

触发仓库调度事件

名称及示例:peter-evans/repository-dispatch

      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.PAT }}
          repository: username/my-repo
          event-type: my-event

仓库地址:https://github.com/peter-evans/repository-dispatch

rsync 文件同步

名称及示例:burnett01/rsync-deployments

      - name: rsync deployments
        uses: burnett01/rsync-deployments@7.0.2
        with:
          switches: -avzr --delete
          path: public/
          remote_path: 目标主机同步目录
          remote_host: 目标主机 IP 地址
          remote_port: 目标主机 SSH 端口
          remote_user: 目标主机用户名
          remote_key: 目标主机 SSH KEY

仓库地址:https://github.com/Burnett01/rsync-deployments

SSH 操作

名称及示例:appleboy/ssh-action

      - name: executing remote ssh commands using password
        uses: appleboy/ssh-action@v1
        with:
          host: SSH host
          username: SSH 用户名
          password: SSH 密码
          port: SSH 端口
          script: |
            cd /root
            rm * -rf

仓库链接:https://github.com/appleboy/ssh-action

其他

HUGO 安装

名称及示例:peaceiris/actions-hugo

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v3
        with:
          hugo-version: '0.145.0'
          extended: true

      - name: Build 
        run: hugo --minify # 执行构建命令

仓库地址:https://github.com/peaceiris/actions-hugo


一个人,看世界,体会孤独,也是成长。

16Reverie

站长

不具版权性
不具时效性

文章内容不具时效性。若文章内容有错误之处,请您批评指正。

目录

欢迎来到webjing的站点,为您导航全站动态

21 文章数
11 分类数
1 评论数
32标签数
最近评论
16Reverie

16Reverie


有用就好~

wl

wl


用上了!谢!