Getting error `EAI_AGAIN ` while using GH action services

Getting this error while setting up a docker postgres service in GitHub Action

Error: getaddrinfo EAI_AGAIN db
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
  errno: 'EAI_AGAIN',
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'db'
}

While setting the postgres container, I am passing those same environment variables to application but before the app runs, it shows this error.

Link to logs: https://github.com/mittalyashu/logchimp/runs/1121285374?check_suite_focus=true#step:6:153

@mittalyashu ,

There are few points you need to understand:

  1. All the the environment variables (include the workflow-level and job-level env) you set for job are mapped only when the job has started on the runner, generally is in the “Set up job” step.

  2. When pass the value of an environment variable to set or update another environment variable, for example using ENV_1 to set ENV_2, the ENV_1 must have been existing on the runner machine with a valid value.

  3. When using the ‘env’ key to set or update the environment variables, if you want set an environment variable with the value of another environment variable, you need to use the env context (env.ENV_NAME) to pass the value. However, you can’t use the env context in the job-level ‘env’ key.

  4. If the called environment variable is a default environment variable that is not in the env context, you need to add a steps at first to run the workflow command ‘set-env’ to add this default environment variable into the env context, or run ‘set-output’ to set it as an output. Then in the subsequent steps, when using the ‘env’ key to set or update an environment variable, you can use the expression “${{env.ENV_NAME}}” or “${{steps.step_id.outputs.output_name}}” to pass the value.

According to above points, in your case, you are using the invalid methods to set the job-level environment variables.