0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

azure functionsを新規作成したときにGithubActionsとの連携するときに「repository 〜 not found」と出る時

Posted at

手順

以下参照(公式
https://learn.microsoft.com/ja-jp/azure/azure-functions/functions-continuous-deployment?tabs=github%2Cazure-pipelines%2Cazure-portal

この操作からyamlを作成するとだいたい以下のようになる

# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy dotnet core app to Azure Function App - project-name

on:
  push:
    branches:
      - main
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_PACKAGE_PATH: 'project-name' # set this to the path to your web app project, defaults to the repository root
  DOTNET_VERSION: '8.0.x' # set this to the dotnet version to use

jobs:
  build-and-deploy:
    runs-on: windows-latest
    permissions:
      id-token: write #This is required for requesting the JWT

    steps:
      - name: 'Checkout GitHub Action'
        uses: actions/checkout@v4

      - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }}

      - name: 'Resolve Project Dependencies Using Dotnet'
        shell: pwsh
        run: |
          pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
          dotnet build --configuration Release --output ./output
          popd
      
      - name: Login to Azure
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID }}
          tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID }}
          subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID }}

      - name: 'Run Azure Functions Action'
        uses: Azure/functions-action@v1
        id: fa
        with:
          app-name: 'project-name'
          slot-name: 'Production'
          package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
          

このまま動かすとリポジトリがPrivateだったりすると
actions/checkout@v4のStepで
Error: fatal: repository 'https://github.com/hogehoge' not found
とエラーが出て進まなくなる。
他の似たようなActionsではならないので意味不明だった。

解決

とりあえず検索した結果
https://github.com/actions/checkout/issues/1555
どうやらこのIssue

なので、
jobs > build-and-deploy > permissions
のセクションに
contents: read
を追加する。

    permissions:
      id-token: write # This is required for requesting the JWT
      contents: read

↑こうですね。
これでちゃんと解決した。

ドキュメントとかテンプレがちょっと古いものがあたったりすると解決に時間かかるな…

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?