-
GitHub Action 介绍
-
简单演示
-
注意事项
-
创建 workflow
-
remote: Write access to repository not granted.
-
速度方面
GitHub Action 介绍
GitHub Actions 是一种持续集成和持续交付 (CI/CD) 平台,可用于自动化构建、测试和部署应用程序,执行代码质量检查,创建和发布软件包,发送通知,执行持续集成和持续部署等等。可以根据自己的需求和工作流程来定义和配置这些自动化任务。
-
官方中文文档[1] -
GitHub Action 市场[2]
可以理解为 GitHub 提供了一台最长可以使用6 小时[3]的云服务器,每次 push 代码时,该云服务器都会按照你提前设定好的流程去执行一遍。
简单演示
以构建简单的 subfinder 子域名收集 - nuclei 漏扫 为例,先使用 subfinder 进行子域名收集,然后使用 nuclei 进行漏扫,最后将结果上传到 GitHub 的当前仓库中。
创建 git 项目,编写.github/workflows/blank.yml
内容如下,基本上都能看懂每一步干啥,每个字段解读可参考官方文档[4]
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Setup Go environment
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: 1.20.1
# 安装subfinder 和 nuclei
- name: Run Install
run: |
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest
# 使用
- name: Run tools
shell: bash
run: |
domain=$(cat input/domain.txt)
subfinder -d $domain -o output/subdomains.txt
nuclei -l output/subdomains.txt -o output/vuln.txt -s medium
# push到当前仓库
- name: Commit files
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add *
git commit -m "commit change file"
- name: GitHub Push
# You may pin to the exact commit or the version.
# uses: ad-m/github-push-action@40bf560936a8022e68a3c00e7d2abefaf01305a6
uses: ad-m/[email protected]
with:
# Token for the repo. Can be passed in using ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
整体目录结构如下:
.
├── .github
│ └── workflows
│ └── blank.yml
├── .gitignore
├── input
│ └── domain.txt // 内容为gm7.org
└── output
└── res.txt
上传到 Github 中,Github 将会通过 Action 自动构建,按照我们设置的流程运行,结果如下。
结果 push 到仓库,可随时查看。
注意事项
创建 workflow
如果要从头写一个 workflow 的话,建议在 Github 中新建模板后再改。
此外右边有语法参考,还可以直接从市场复制想要的东西,很方便。
remote: Write access to repository not granted.
需要在当前仓库的设置中,赋予 workflow 写权限。
速度方面
个人感觉速度比较慢,比较欠缺,有这精力不如直接买台服务器配了,一劳永逸。
参考资料
官方中文文档: https://docs.github.com/zh/actions/quickstart
[2]GitHub Action市场: https://github.com/marketplace?type=actions
[3]6小时: https://docs.github.com/zh/actions/learn-github-actions/usage-limits-billing-and-administration
[4]官方文档: https://docs.github.com/zh/actions/learn-github-actions/understanding-github-actions#%E4%BA%86%E8%A7%A3%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B%E6%96%87%E4%BB%B6
- END -
原文始发于微信公众号(初始安全):GitHub Action 云扫描器
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论