文章目录

就很尴尬,白天写了博客,回头就发现GitLab发了邮件过来,pipelines执行失败了。但是陪孩子也没空去看。

安顿孩子睡了以后,想着看看怎么回事,结果就很尴尬。 The gsgundam namespace has exceeded its pipeline minutes quota. Buy additional pipeline minutes, or no new jobs or pipelines in its projects will run. 就是说时间到头了。那要什么时候才能再用呢?查了下,说一个月400分钟。难道是这个月调试hexo的新问题提交太多次了?

咨询了一下 陈总 ,说github的时间肯定够。果然,GitHub的Actions每月有2000分钟,存储上限是500MB。那么又试着转GitHub吧。

参考了GitHub Docs里 从 GitLab CI/CD 迁移到 GitHub Actions 的官方教程和另一篇来自于网友的 如何正确的使用 GitHub Actions 实现 Hexo 博客的 CICD

直入正题吧,项目里建立.gihub/workflows/upload2ftp.yml,写入一下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: upload2ftp
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
container: node:12.14.1

steps:
- uses: actions/checkout@v2

- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/node_modules/

- name: Install dependencies
run: |
npm install hexo-cli -g
test -e package.json && npm install
hexo generate

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: public
path: public

- name: Deploy 2 FTP
run: |
apt-get update -qq && apt-get install -y -qq lftp
lftp -c "set ftp:ssl-allow false; set ftp:ignore-pasv-address true; set ftp:prefer-epsv no; set ftp:charset gbk; set file:charset utf-8; debug; open -u ${{ secrets.USERNAME }},${{ secrets.PASSWORD }} ${{ secrets.HOST }}; mirror -R public/ ./htdocs --verbose -p --ignore-time --transfer-all --parallel=5 --exclude-glob .git* --exclude .git/"

大概需要注意的就是,依然为了不要暴露密码,所以把ftp相关信息写到了项目的action secrets中。

测试一下,好像没什么问题。

如果这边时间也不够了,下个月又切另一边,哈哈。

♦ 本文固定连接:https://www.gsgundam.com/archive/2021-11-29-gitlab-cicd-migrate-to-github-actions/

♦ 转载请注明:GSGundam 2021年11月29日发布于 GSGUNDAM砍柴工

♦ 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。

♦ 原创不易,如果页面上有适合你的广告,不妨点击一下看看,支持作者。(广告来源:Google Adsense)

♦ 本文总阅读量