yaml - 使用 Github 操作部署 Google 云功能:无法读取“https://github.com”的用户名
问题描述
我正在尝试通过 GitHub Actions 设置 CICD 管道;目标是在主分支发生更改后立即触发功能部署。
以下是我的 dedicated.yaml 代码:
name: Deploy Function
# https://sourcery.ai/blog/github-actions/
on:
push:
branches:
- main
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: install quality dependencies
run: pip install -e ".[quality]"
- name: check code quality
run: make quality
test:
runs-on: ubuntu-latest
needs: quality
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: install testing dependencies
run: pip install -e ".[testing]"
- name: run unit-test
run: make test
build:
runs-on: ubuntu-latest
# It breaks the pipeline if any of them is not passed
# Comment here and on top to exclude
needs: [quality, test]
env:
PROJECTID: my_project_id
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
# base46encoded json file for service account
service_account_key: ${{ secrets.PRODUCTION_FUNCTION_KEY }}
export_default_credentials: true
- name: install testing dependencies
run: make install-prod
- name: extract requirements
run: python -m pip freeze > src/requirements.txt
- name: deploy function
working-directory: src
run: |
gcloud functions deploy my_function \
--runtime=python39 \
--trigger-http \
--project ${{ env.PROJECTID }} \
--set-env-vars CSF_DISCOUNT_BUCKET=csf-discount \
--entry-point=predict \
--region=europe-west3 \
--max_instances=5 \
--memory=1024MB
本质上,我的主 GitHub 存储库中有一个“src”存储库,其中包含我的函数的完整源代码。
但是,在运行时,以下错误会停止部署(“my_”替换真实姓名):
Cloning https://github.com/my_organization/my_function_repo (to revision 990f313e622a7d485896e8c99f63501b603a50dd) to ./src/my_function_repo
Running command git clone -q https://github.com/my_organization/my_function_repo /workspace/src/my_function_repo
fatal: could not read Username for 'https://github.com': No such device or address
WARNING: Discarding git+https://github.com/my_organization/(...) . Command errored out with exit status 128: git clone -q https://github.com/my_organization/my_function_repo /workspace/src/my_function_repo Check the logs for full command output.
Collecting cachetools==4.2.2
Downloading cachetools-4.2.2-py3-none-any.whl (11 kB)
Collecting DateTime==4.3
Downloading DateTime-4.3-py2.py3-none-any.whl (60 kB)
ERROR: Could not find a version that satisfies the requirement my_function_repo (unavailable) (from versions: none)
ERROR: No matching distribution found for my_function_repo (unavailable); Error ID: c84b3231
我该如何解决这个问题并完成部署?
解决方案
推荐阅读
- python - 如何防止赛车条在动画条形图中重叠?
- python - 取整数的最右边 n 位
- jboss - jboss 4 到 jboss 7.1 部署 .war 迁移问题
- spring - 在 @Query 中具有多个构造函数的 Spring Data JPQL
- google-apps-script - CSS变量在来自谷歌应用脚本的电子邮件中不起作用
- python - 为什么对同一个 tf.data.Dataset 的迭代每次迭代都会给出不同的数据?
- ruby-on-rails - Docker 化了一个现有的小型 Rails 应用程序。适用于本地但不适用于 Heroku
- java - JAXB - anyType - 重复的命名空间前缀 - 复杂的解决方案
- python - 继承创建对象 - 定义大小和委托对象
- amazon-web-services - AWS Step Function - 在条件下停止状态机执行