修复GitHub Action 存储上限错误 工作流命令和版本的弃用警告

447 阅读2分钟

100962820_p0.png

凌晨更新了上一篇就睡了,早上起来才发现 GitHub Action 竟然运行失败了。

第一条就算了,存储满了,很明确。但是后面怎么出来几条别的警告?

20230102112229.png

Artifact storage quota has been hit

这个提示再明确不过了,输出存储配额满了。

说来一开始我就觉得奇怪,因为在做 GitLab CI/CD 配置的时候,其中就有关于这方面的过期配置,但是 GitHub 却没有。今天查了下,2020年10月14日的时候他们加上了(github.com/orgs/commun… upload-artifact 部分加上相关配置即可:

1
2
3
4
5
6
- name: Upload artifacts
    uses: actions/upload-artifact@v3
    with:
    	name: public
    	path: public
    	retention-days: 3 # <= 这里可以设置保留天数

当然,因为满了,所以还得把以前的全都删了 🙄 。搜索了下,市场里有一个第三方提供的相关操作(github.com/marketplace…

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
name: Remove old artifacts

on: schedule: # Every day at 1am - cron: '0 1 * * *'

jobs: remove-old-artifacts: runs-on: ubuntu-latest timeout-minutes: 10

steps:
- name: Remove old artifacts
  uses: c-hive/gha-remove-artifacts@v1
  with:
    age: <span style="color: #BA2121">'15 days'</span> <span style="color: #408080; font-style: italic"># '&lt;number&gt; &lt;unit&gt;', e.g. 5 days, 2 years, 90 seconds, parsed by Moment.js</span>
    <span style="color: #408080; font-style: italic"># Optional inputs</span>
    <span style="color: #408080; font-style: italic"># skip-tags: true</span>
    <span style="color: #408080; font-style: italic"># skip-recent: 5</span>

此外,还可以在项目设置的 Action 中,找到 Artifact and log retention ,把存储保留的时间调整更短(目前我还没有找到手动删除日志的方法,知道的朋友可以分享一下)。

官方在 upload-artifact 的 issue 中也提到,清除了存储以后,可能计费系统还需要一点时间同步。所以等一等就好了。

Node.js 12 actions are deprecated

原来如此,由于我上次解决 Node.js 高版本报错时(参见《解决Hexo在 Node.js 14 下出现的 Accessing non-existent property 'xxx' of module exports inside circular dependency 问题 》),只修改了 GitLab 的 CI/CD 持续集成配置,没有修改 GitHub 这边,所以还在用老版本安全稳当的跑着。

解决方案自然也简单,我修改为了 16.16.0 LTS 版本。

1
2
3
4
jobs:
  build:
    runs-on: ubuntu-latest
    container: node:16.16.0

The save-state command is deprecated

同时警告的还有图中 set-output 这个命令,但是我在 yml 文件里却并没有找到相关内容。那猜想大概就是用到的几个 action 内置操作了吧。

于是把 checkoutcacheupload-artifact 都从 @v2 改为了 @v3。

似乎一切正常了。

[2023年01月02日原始发布于本作者博客]

👇点击“阅读原文”可恢复文章内所有链接哦!

阅读原文:www.gsgundam.com/2023/01/202…