Search code examples
azuregithub-actionsazure-container-registry

Github workflow failing with error - Error: Error: Input required and not supplied: username


for an existing app service webapp, running in my azure subscription, which uses code - from https://github.com/microsoft/sample-app-aoai-chatGPT, I forked the code in https://github.com/manuchadha1979/sample-app-aoai-chatGPT and changed an html file. The workflow is failing with error

enter image description here

I am new to this so not really sure what is going on at times. I haven't set up ACR_USERNAME or anything else specifically as I thought that, because I am changing an existing app service's code, I don't need to. Do I and how?


Solution

  • The error you're encountering during your GitHub Actions workflow suggests that the workflow is expecting a username for the Azure Container Registry login, but it hasn't been provided. You can resolve this as below.

    1. Azure Container Registry (ACR) Setup:

      Ensure that you have an Azure Container Registry set up. enter image description here

    Once you have ACR set up, you'll have a username and a password that you can use to log in to it. enter image description here

    1. GitHub Repository Secrets:

    Go to your GitHub repository where you forked the code. Click on "Your repositories" which appears on the dropdown menu when you click on your profile picture in the top-right corner. Choose the repository where you forked the code. Once you are in your repository, look for the "Settings" tab, which should be on the right side of the screen, alongside "Code", "Issues", "Pull Requests", etc. enter image description here

    Click on "Settings", and then on the left sidebar that appears, scroll until you find the "Secrets" section. Under "Secrets", you will find "Actions". Click on it. enter image description here

    Here, you can add new secrets by clicking on "New repository secret". Enter ACR_USERNAME as the name and your Azure Container Registry username as the value. Repeat the process and add ACR_PASSWORD as another secret with the corresponding password as the value. for ACR username inside secret give the full name youracrname.azurecr.io enter image description here

    Remember to save each secret after you've added it. These secrets will then be available in your GitHub Actions workflows as you've defined in the YAML file.

    1. Update Workflow File:

      • Open your .github/workflows YAML file where the build and deployment process is defined. enter image description here

      • Make sure that the step which logs into the Azure Container Registry uses the secrets you set up. It should look something like this:

    - name: Login to Azure Container Registry
      uses: azure/docker-login@v1
      with:
        username: ${{ secrets.ACR_USERNAME }}
        password: ${{ secrets.ACR_PASSWORD }}
    

    This tells the workflow to use the username and password from your repository secrets for logging in to ACR. After you make the changes, commit the updated workflow file to your repository. This should trigger the workflow again with the new changes. If everything is set up correctly, it should pass the login step without issues.

    Reference documents:

    Create ACR

    Login to ACR from Github Actions

    Configure Github actions with ACR