我正在尝试执行一个 github 操作,该操作使用代码函数源代码构建一个 zip 文件并将其上传到 Google Cloud Storage
然后我有一个使用这个 zip 文件部署云功能的 terraform 存储库。
问题是,当我在本地环境 - WSL Ubuntu 18-04 - 上压缩这些文件并将 zip 上传到同一个存储中时,我可以继续进行 terraform 部署,一切顺利。
压缩../0.0.9.zip *
但是,从 Github Action 执行的相同命令会创建一个 zip 文件,并按预期将其推送到云存储,我也可以下载并打开它,但云函数部署的云构建过程不起作用。我不明白它们之间有什么区别。
以下是 Github Action 的工作流程:
name: Function Deploy
on:
push:
tags:
- '*'
jobs:
build:
name: 'Build & Push'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Using Node
uses: actions/setup-node@v2
with:
node-version: "16.x"
- name: Installing Node Modules
run: npm install
- name: Building
run: npm run build
- name: Copy files
run: |
cp package.json ./lib/package.json
cp package-lock.json ./lib/package-lock.json
cp cloudbuild.yaml ./lib/cloudbuild.yaml
- name: Zipping Version
run: |
cd lib
zip ../${{ github.ref_name }}.zip *
cd ..
- name: Auth to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Uploading
uses: google-github-actions/upload-cloud-storage@v1
with:
path: ${{ github.ref_name }}.zip
destination: ${{ secrets.GCP_BUCKET_NAME }}
以下是来自云构建的错误日志:
starting build "ac767a2c-5242-4315-8b20-f8672206b04c"
FETCHSOURCE
Fetching storage object: gs://gcf-sources-xxxxx-europe-west1/ln-func-bcareer-e8268533-f38c-44a7-b62e-ec74a3affe0b/version-2/function-source.zip#1669544086773073
Copying gs://gcf-sources-xxxxxx-europe-west1/ln-func-bcareer-e8268533-f38c-44a7-b62e-ec74a3affe0b/version-2/function-source.zip#1669544086773073...
/ [0 files][ 0.0 B/ 31.6 KiB] / [1 files][ 31.6 KiB/ 31.6 KiB]
Operation completed over 1 objects/31.6 KiB.
Archive: /tmp/source-archive.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of /tmp/source-archive.zip or
/tmp/source-archive.zip.zip, and cannot find /tmp/source-archive.zip.ZIP, period.
两个过程中使用的 zip 命令相同,且版本相同。
Github Action 生成的 zip 文件可以从云存储中下载并在 Windows 中正常打开:
但是在 Build Storage 上获取时,它无法再打开:
而我本地生成的 zip 文件也可以从云存储中下载并打开
我错过了什么 ?