在部署我的网站期间,在哪里以及如何捕获gsutil错误?

人气:534 发布:2022-10-16 标签: continuous-integration continuous-deployment google-cloud-platform google-cloud-storage gcloud

问题描述

我有一个托管在谷歌云存储上的个人网站。我在我的存储桶上部署网站的方式如下:

Github Actions在我按下开发分支时运行make deploy Make Deploy正在运行名为bin/deploy.sh的外壳脚本

我的Google Cloud帐户存在计费问题,因此我无法修改GCS存储桶上的任何内容。事实上,如果我在本地运行Make Deploy,我会得到这个错误日志:

AccessDeniedException: 403 The project to be billed is associated with a delinquent billing account.
CommandException: 29 files/objects could not be copied/removed.
make: *** No rule to make target `do', needed by `deploy'.  Stop.

我的Github操作管道成功,未报告任何错误。

我应该在何时以及如何捕获gCloud错误?

ploy.sh

# set website config
gsutil web set -m index.html -e 404.html gs://pierre-alexandre.io

# add user permissions
gsutil iam ch allUsers:legacyObjectReader gs://pierre-alexandre.io

# copy the website files!
gsutil -m rsync -d -r public_html gs://pierre-alexandre.io

生成文件

deploy: $(shell ./bin/deploy.sh)

.github/workflows/main.yml

name: CI
on:
  push:
    branches: [ develop ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Deployment to production server 
        run: |
          echo deploying new version on pierre-alexandre.io ...
          echo make deploy

推荐答案

除了@Mousumi提供的内容外,请通过编写一些shell script来查找如何捕获Gstil错误的示例。

955