【发布时间】:2020-10-04 03:03:09
【问题描述】:
我正在使用 Github Actions 在我的项目中实施 CI 管道。目前,我正在尝试使用 actions/cache@v2 来缓存 yarn cache dir 以改善管道时间。不幸的是,总是在操作/缓存@v2 运行时,我在作业后遇到错误:/bin/tar: unrecognized option: posix。完整的日志是:
Post job cleanup.
/usr/bin/docker exec 4decc52e7744d9ab2e81bb24c99a830acc848912515ef1e86fbb9b8d5049c9cf sh -c "cat /etc/*release | grep ^ID"
/bin/tar --posix -z -cf cache.tgz -P -C /__w/open-tuna-api/open-tuna-api --files-from manifest.txt
/bin/tar: unrecognized option: posix
BusyBox v1.31.1 () multi-call binary.
Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [--exclude PATTERN]... [FILE]...
Create, extract, or list files from a tar file
c Create
x Extract
t List
-f FILE Name of TARFILE ('-' for stdin/out)
-C DIR Change to DIR before operation
-v Verbose
-O Extract to stdout
-m Don't restore mtime
-o Don't restore user:group
-k Don't replace existing files
-Z (De)compress using compress
-z (De)compress using gzip
-J (De)compress using xz
-j (De)compress using bzip2
-a (De)compress using lzma
-h Follow symlinks
-T FILE File with names to include
-X FILE File with glob patterns to exclude
--exclude PATTERN Glob pattern to exclude
Warning: Tar failed with error: The process '/bin/tar' failed with exit code 1
我按照官方action cache repository的例子。这是我的 CI.yml 的 sn-p
# Configure cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
由于上述错误,没有创建缓存,也没有提高流水线时间。我尝试更改 hasFiles 表达式和整个密钥,但没有成功。
我的问题是:我在使用 Action Cache 时是否犯了一些错误?谁能帮我解决这个问题?谢谢。
【问题讨论】:
-
您是在使用非标准的
PATH还是在 Docker 容器或其他非默认操作系统中运行此操作? -
@bk2204 是的,它在 Docker 容器中运行。您可以访问完整的工作流文件here
标签: github github-actions