惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
雷峰网
雷峰网
Recent Announcements
Recent Announcements
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
博客园_首页
The Cloudflare Blog
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
S
SegmentFault 最新的问题
P
Proofpoint News Feed
Y
Y Combinator Blog
Jina AI
Jina AI
博客园 - 聂微东
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
F
Full Disclosure
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
T
Tailwind CSS Blog
J
Java Code Geeks
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
W
WeLiveSecurity
PCI Perspectives
PCI Perspectives
Attack and Defense Labs
Attack and Defense Labs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
宝玉的分享
宝玉的分享
IT之家
IT之家
Hacker News: Ask HN
Hacker News: Ask HN
The Register - Security
The Register - Security
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs

Surmon.me

一人有限集团 你就是不敢 创造力是温柔的谎言 人类正在退出人类 AI 代替不了这样的你 脉冲点火背后的架构设计 基于 Cloudflare 生态的 AI Agent 实现 NodePress 支持用户登录了 从统计学习到通用智能 2025 投资报告:走慢的路 无依之地 会杀人的菩萨 无我不是共识 文化的积重与偏见 当下即安 科学的尽头是态度 无我不是 Egoless 信仰不因恐惧而存在 世间无解的矛与盾 先别急着做些什么 佛不需要你的皈依 真理的幻觉 两扇大门 造心里的浮屠 自胜者强 逻辑与智慧 真的相 快乐的秘密 只需愿意 是名体验 最深沉的梦 森林里倒下的树 现象与相 庸人自扰 React 与 Vue 的完美融合 开心就好吗 与原生家庭和解 两支毒箭 怎么自净其意 一尘不染 一片白云 让风穿膛而过 喝下去,然后闭嘴 活在当下 当纠结发生时 唯「我」独尊 一场把戏(时间) 一场把戏(二元对立) “我” 和 “我” 谁是众生? 船里没有人 玫瑰不需要说话 没有人能渡任何人 你我为轮,使之不再 当我们在谈论独立时 自我约束就是最好的自我接纳 从善与恶的表象出发 佛法不是心理学 别人眼中的你并不是你 高高山上走 祝你心想事成 祝你的噩梦早日发生 道是无情却有情 裙子只为自己而穿 不要盲目地评估自己 先别急着 “爱自己” 让生命欣然舞动 你无法复制乔布斯 符号不是目的 如果一件事发生了 每当我起心动念时 爱出者爱返 理解不是尊重的基础 在没有解决自己的问题之前 “知足常乐” 不是比较 逻辑是无法成为信仰的 买不到的自由 成为诵经者 伤口听不懂大道理 是立场让你不自由 - Unfreedom 天雨大不润无根之草 做自己的神 当心诱惑本身 牛洞冥思录 修罗启示录 让大脑自举 我更喜欢叫它无梦寺 存在主义也许不是解药 出南洋记 2022 的所有答复 没意义的表达 思考的记录 故宫暂行之幻想 极端的比较 解构的终极 舍利子是如何炼成的 心要野 佛教的偏见 文艺青年 我是动物
GitHub Actions 能干啥
Surmon · 2019-10-09 · via Surmon.me

原创

我已经用上 Actions 了,在我看来它不仅仅是一个 CI 工具,它更像一个「 工作流控制器 」。

你可以把它打造为 CI、Bot、跳板机、文章发布器、Issues 统计器...任何你需要的工具或平台。

Actions 事件继承于之前的 API/Webhooks,自身提供了 Docker 环境,这意味着你拥有了无限编程能力的 “工作流定制权”。

比如,在实际的使用中,我的 angular-admin (web)、nodepress (nodejs) 两个项目的部署流程,

前者在 Actions 中的流程为:

测试(前提) -> 编译 -> 打包 -> 压缩 -> 通过 scp 将压缩包传给生产机 -> 执行生产机部署脚本 -> 完成部署

代码:

        
        

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253

name: Deploy to server on: pull_request: types: [closed] branches: - master jobs: deploy: if: github.event.pull_request.merged == true name: Deploy to server runs-on: ubuntu-latest strategy: matrix: node-version: [10.x] steps: - name: Checkout uses: actions/checkout@master with: ref: master - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - name: Install Dependencies run: npm ci - name: Build run: npm run build - name: ls and pwd run: | pwd ls -la - name: Compress dist files run: tar -zcvf ./dist.tar.gz -C ./dist/angular-admin/ . - name: Copy file to server uses: appleboy/scp-action@master with: timeout: 3m overwrite: true host: ${{ secrets.HOST }} username: ${{ secrets.USER }} password: ${{ secrets.PASSWORD }} source: ./dist.tar.gz target: ${{ secrets.WWW_PATH }}/angular-admin/product/ - name: Exec deploy script with SSH uses: appleboy/ssh-action@master with: command_timeout: 3m host: ${{ secrets.HOST }} username: ${{ secrets.USER }} password: ${{ secrets.PASSWORD }} script: | sh ${{ secrets.WWW_PATH }}/angular-admin/.deploy/main.sh

后者在 Actions 中的流程为:

测试 -> 编译 -> 构建测试 -> 执行生产机部署脚本 -> 完成部署

代码:

        
        

123456789101112131415161718192021

name: Deploy to server on: pull_request: types: [closed] branches: - master jobs: deploy: if: github.event.pull_request.merged == true name: Deploy to server runs-on: ubuntu-latest steps: - name: Exec deploy script with SSH uses: appleboy/ssh-action@master with: command_timeout: 10m host: ${{ secrets.HOST }} username: ${{ secrets.USER }} password: ${{ secrets.PASSWORD }} script: sh ${{ secrets.WWW_PATH }}/nodepress/.deploy/main.sh

部署脚本:

        
        

123456789101112131415161718192021222324252627282930313233343536

#!/bin/bash WEB_PATH=$(dirname $0) # WEB_USER='root' # WEB_USERGROUP='root' echo "[deploy] Start deployment..." echo "[deploy] Fetch and rebuilding..." cd $WEB_PATH cd .. echo "[deploy] path:" $(pwd) echo "[deploy] pulling source code..." git fetch --all && git reset --hard origin/master && git pull git checkout master # echo "changing permissions..." # chown -R $WEB_USER:$WEB_USERGROUP $WEB_PATH # chmod -R 777 $WEB_PATH # sync && echo 3 | sudo tee /proc/sys/vm/drop_caches echo "[deploy] Install dependencies..." npm ci echo "[deploy] Stop service..." pm2 stop nodepress echo "[deploy] Remove old dist..." rm -r ./dist/* echo "[deploy] Building..." npm run build echo "[deploy] Restarting..." pm2 restart nodepress echo "[deploy] Finished."

这一切都在 Actions 中完成,除去目标生产服务所必须的环境,你不需要额外多做什么; 反而,你可以将 工作流、部署、测试、生产代码... 等一系列上下游相关的配置或文件约束在同一个项目,甚至同一个目录内, 使项目始终紧密耦合在同一个单元内,减少维护成本。

所以,我已经把 SRE 服务 下线并废弃了。

祝使用愉快。