hashicorp / setup-terraform

Sets up Terraform CLI in your GitHub Actions workflow.
https://developer.hashicorp.com/terraform/tutorials/automation/github-actions
Mozilla Public License 2.0
1.37k stars 240 forks source link

Path issue in github self-hosted runners Setup #424

Open adi18fw opened 3 months ago

adi18fw commented 3 months ago

I have created 8 GitHub runners on my local machine and set them up. However, when I try to run them using runsvc.sh, I encounter the following errors:

/github-runners/r1/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r2/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r3/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r4/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r5/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r6/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r7/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory /github-runners/r8/runsvc.sh: line 17: ./externals/node16/bin/node: No such file or directory

However, if I navigate to ./externals/node16/bin/node in r1 and execute it directly, it works fine and opens the Node.js environment.

Here is my service file:

[Unit] Description=Manage GitHub Actions Runners After=network.target

[Service] Type=simple User=myuser WorkingDirectory=/home/myuser/github-runners/

ExecStart=/bin/bash -c 'for i in {1..8}; do /home/myuser/github-runners/r$i/runsvc.sh start --instance r$i; done'

Restart=always RestartSec=3

[Install] WantedBy=multi-user.target

rsi-mrobinson commented 2 months ago

Seeing this issue as well with self-hosted runners. Disabling the wrapper by setting terraform_wrapper=false clears the error but seems to cause all stdout, stderr outputs to not populate.

update:

Worked out a workaround for this just throwing the plan into github_output

Setup Terraform (I'm using clowdhaus's action to grab the version based on my configuration):

- name: Terraform min/max versions
  id: minMax
  uses: clowdhaus/terraform-min-max@v1.3.1

- name: Setup Terraform
  uses: hashicorp/setup-terraform@v3
  with:
    terraform_version: ${{ steps.minMax.outputs.maxVersion }}
    terraform_wrapper: false

Run the plan and set the output:

- name: Terraform Plan
  id: plan
  run: |
    terraform plan >/dev/null -no-color -out=tfplan
    plan=$(terraform show tfplan -no-color)
    {
      echo "PLAN<<EOF"
      echo "${plan}"
      echo "EOF"
    } >> $GITHUB_OUTPUT
  continue-on-error: true

Then in your script step set the plan variable

- uses: actions/github-script@v7
  env:
    PLAN: ${{ steps.plan.outputs.plan }}