我正在嘗試使用 github 操作來建立帶有程式碼函數原始碼的 zip 檔案並將其上傳到 Google Cloud Storage
然後我有一個 terraform 儲存庫,它使用此 zip 檔案部署雲端功能。
問題是,當我在本地環境(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 中正常開啟:
但是,當在構建存儲上獲取時,它無法再打開:
同樣,我本地的 zip 檔案也可以從雲端建置儲存下載和打開
我錯過了什麼 ?