凌晨更新了上一篇就睡了,早上起来才发现 GitHub Action
竟然运行失败了。
第一条就算了,存储满了,很明确。但是后面怎么出来几条别的警告?
Artifact storage quota has been hit
这个提示再明确不过了,输出存储配额满了。
说来一开始我就觉得奇怪,因为在做 GitLab
CI/CD 配置的时候,其中就有关于这方面的过期配置,但是 GitHub
却没有。今天查了下,2020年10月14日的时候他们加上了(https://github.com/orgs/community/discussions/25458),所以只要我们在 upload-artifact
部分加上相关配置即可:
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: public
path: public
retention-days: 3 # <= 这里可以设置保留天数
当然,因为满了,所以还得把以前的全都删了 🙄 。搜索了下,市场里有一个第三方提供的相关操作(https://github.com/marketplace/actions/remove-artifacts):
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: '15 days' # '<number> <unit>', e.g. 5 days, 2 years, 90 seconds, parsed by Moment.js
# Optional inputs
# skip-tags: true
# skip-recent: 5
此外,还可以在项目设置的 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
版本。
jobs:
build:
runs-on: ubuntu-latest
container: node:16.16.0
The save-state command is deprecated
同时警告的还有图中 set-output
这个命令,但是我在 yml 文件里却并没有找到相关内容。那猜想大概就是用到的几个 action 内置操作了吧。
于是把 checkout
、 cache
、 upload-artifact
都从 @v2 改为了 @v3。
似乎一切正常了。
[2023年01月02日原始发布于本作者博客]
👇点击“阅读原文”可恢复文章内所有链接哦!
阅读原文:https://www.gsgundam.com/2023/01/2023-01-02-z11-fix-github-action-storage-error-and-deprecation-warnings/