在使用此操作“azure/ docker -login@v1”构建和推送对接者图像时,我收到以下错误消息:
Run azure/docker-login@v1
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '@actions/core'
Require stack:
- /home/runner/work/_actions/azure/docker-login/v1/lib/login.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/work/_actions/azure/docker-login/v1/lib/login.js:13:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) ***
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/runner/work/_actions/azure/docker-login/v1/lib/login.js' ]
***这是我的yaml工作流的相关部分:
build-and-deploy:
needs: [deploy_checks]
environment: ${{ needs.deploy_checks.outputs.env_name }}
runs-on: ubuntu-latest
steps:
# checkout the repo
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Build and push image'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/image_name:${{ github.sha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/image_name:${{ github.sha }}注意,就在今天之前,工作流还在运行,我遇到了这个问题。
发布于 2022-11-23 06:08:03
似乎存在依赖模块或权限问题;请确保GitHub操作具有运行工作流的足够权限。
检查服务负责人的信息。
Step1:
az ad sp create-for-rbac \
--name <SERVICE_PRINCIPAL_NAME> \
--role "contributor" \
--scopes /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME> \
--sdk-auth由此产生的产出如下:
{
"clientId": "<GUID>",
"clientSecret": "<GUID>",
"subscriptionId": "<GUID>",
"tenantId": "<GUID>",
}Step2:有必要授予GitHub操作SP将图像拉出并推送到ACR的权限。
# Get the id
registryId=$(az acr show --name <registry-name> --query id --output tsv)
# Grant the 'AcrPush' role to SP
az role assignment create --assignee <ClientId> --scope $registryId --role AcrPush
# Grant the 'AcrPull' role to SP
az role assignment create --assignee <ClientId> --scope $registryId --role AcrPull如果使用了Docker-登录操作,请确保登录服务器与图像的完整路径匹配。如果它使用的是完全限定的路径,请指定图像示例的整个路径,如docker push xxx.docker.io/repo/image
**注意:安装依赖项的操作并没有这么快,但至少您不需要提交依赖项。确保维护正确的依赖关系版本。**
https://stackoverflow.com/questions/74531348
复制相似问题