Github Actions Error: No such file or directory - github-actions

Trying to troubleshoot my terraform init step, but I'm getting Error: No such file or directory
Even if I add the pwd as step 2 shown below, still getting Error: No such file or directory. This is working in other pipelines, but none of the new pipelines are working with the same commands.
Was there an update to GHA? I know they updated Helm, but did something else change that would adjust the behavior?
update-terraform-env:
name: "Create or Update Terraform Environment"
needs: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.TERRAFORM_WORKING_DIR }}
steps:
- name: Checkout Source
uses: actions/checkout#v2
- name: Get directory
run: pwd
- name: Setup Terraform
uses: hashicorp/setup-terraform#v1.2.1
with:
terraform_version: 0.13.0
- name: Terraform Init
id: tf-init
run: terraform init

The env.TERRAFORM_WORKING_DIR was initialized to a path that didn't exist. (development which didn't exist, instead of develop which did).
The error of Error: No such file or directory was misleading as it seemed that the step command is failing, when it's actually the working directory for the entire job.

Related

What is skaffold doing after skaffold build pushed successfully

When I run skaffold in a github workflow like this
skaffold build
it calls the gradle jib correctly, creates an image and pushes it to the ghcr successfully. Grdale finishes successfully as can be seen in the log. Nevertheless, something happens afterwards that fails. It seems someone tries to access the just built image but is not authorized. This does not happen, if I execute it locally. And it does not fail in the github workflow if I call gradlew jib directly without skaffold being involved.
Built and pushed image as ghcr.io/tobias-neubert/motd-service:453f4c4-dirty
BUILD SUCCESSFUL in 11s
4 actionable tasks: 4 executed
time="2023-02-15T12:07:09Z" level=error msg="No matching credentials were found for \"ghcr.io\""
time="2023-02-15T12:07:09Z" level=error msg="No matching credentials were found for \"ghcr.io\""
getting image: GET https://ghcr.io/token?scope=repository%3Atobias-neubert%2Fmotd-service%3Apull&service=ghcr.io: UNAUTHORIZED: authentication required
Error: Process completed with exit code 1.
The github workflow:
name: Build and push motd-service
on:
push:
permissions:
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout#v3
- name: Set up Java
uses: actions/setup-java#v2
with:
java-version: 17
distribution: temurin
- name: Setup Gradle
uses: gradle/gradle-build-action#v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Install skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Deactivate collecting skaffold metrics
run: skaffold config set --global collect-metrics false
- name: Build the motd image
env:
GH_PASSWORD: '${{ secrets.GITHUB_TOKEN }}'
run: skaffold build
Does anybody know what happens here?
It tries to fetch the digest of the new image, which it needs to render the k8s resources. Pushing the image was made by gradle. The jib plugin is configured to use environment variables for authenticating against ghcr.io. But skaffold does not know about those. So it fails to authenticate. A docker login does the trick, although it is not safe in a CI. So now I have to search for a better way to tell skaffold to authenticate against the registry

Backstage Unable to use mkdocs to create Tech Docs for an existing component

I have enabled Github actions to create Tech docs after a commit. Below is the workflow file written to create Md files. But "techdocs-cli generate --no-docker --verbose" command fails with the below error. Can someone please help with the issue?
Failed to generate docs from /home/runner/work/myapp3/myapp3 into /home/runner/work/myapp3/myapp3/site; caused by unknown error 'Command mkdocs failed, exit code: 1'
workflow file:
name: Publish TechDocs Site
on:
push:
branches: master
jobs:
publish-techdocs-site:
runs-on: ubuntu-latest
env:
TECHDOCS_S3_BUCKET_NAME: XXX
AWS_ACCESS_KEY_ID: XXX
AWS_SECRET_ACCESS_KEY: XXX
AWS_REGION: XXX
ENTITY_NAMESPACE: 'default'
ENTITY_KIND: 'Component'
ENTITY_NAME: ‘XXX’
steps:
- name: Checkout code
uses: actions/checkout#v2
- uses: actions/setup-node#v2
- uses: actions/setup-python#v2
- name: Install techdocs-cli
run: sudo npm install -g #techdocs/cli
- name: Install mkdocs and mkdocs plugins
run: python -m pip install mkdocs-techdocs-core==1.*
- name: Generate docs site
run: techdocs-cli generate --no-docker --verbose
- name: Publish docs site
run: techdocs-cli publish --publisher-type awsS3 --storage-name $TECHDOCS_S3_BUCKET_NAME --entity $ENTITY_NAMESPACE/$ENTITY_KIND/$ENTITY_NAME
I had the same issue and it was resolved once you had the right folder structure where you have the mkdocs.yml file.
As long as you have a docs folder in the same root structure with the .md file that needs to be published.
The same .md file needs to be configured in the navigation section of the mkdocs.yml file as well

GitHubActions Runner Error: Command failed: go env GOPATH

We have GitHubActions and we run it in an Centos Server. We have set the root's .bashrc as export GOROOT=/opt/go export PATH=$PATH:$GOROOT/bin
In the Github Actions we have the file:
setup:
needs: cleanup
name: Setup
runs-on: [self-hosted, Linux, X64, CentOS-Linux-7.9]
services:
postgres:
image: postgres:latest
- name: Set up Go 1.17
uses: actions/setup-go#v2
with:
go-version: 1.17
# id: Go
- run: go version
- name: Checkout code into go module directory
uses: actions/checkout#v2
When Github Actions runs this , it throws the error:
0s
Run actions/setup-go#v2
with:
go-version: 1.17
stable: true
token: ***
...
Setup go stable version spec 1.17
Found in cache # /opt/actions-runner/_work/_tool/go/1.17.11/x64
Added go to the path
missing $GOPATH
Error: Command failed: go env GOPATH
missing $GOPATH
Can someone please help with this error?
The Go installation is working and on the Linux box as root 'go version' works.
That looks like actions/setup-go issue 116 which includes:
I believe the reason of issue is missing $HOME variable on the self-hosted runners.
The missing HOME variable makes it so that Go is not able to make default folders for GOPATH and GOCACHE and such.
So double-check what echo $HOME displays in your runner.
The OP AwsGeek confirms in the comments:
First as suggested I did an echo $HOME and it was empty and under the env: I added the value for home env: HOME: "/home/xxxx-account"

No such file or directory on a simple shell command on GitHub Actions

I have the following job
deploy-binary:
needs: checkout-project
runs-on: some-debian-machine
defaults:
run:
working-directory: ${GITHUB_WORKSPACE}
steps:
- name: test current working directory
run: pwd
Why does it fail with the following error?
Run pwd
Error: No such file or directory

Publish GitHub Action to Marketplace: Unexpected value 'steps'

I was using the workflow below in a project. However, I wanted to share this with other people and figured posting it as a GitHub Action to the marketplace would be the most user-friendly option. I created a new repo with action.yml and other required files. However, even after editing the workflow, I was unable to get past the Set up job stage. I would like to know which tweaks I need to make in order to have a valid action.yml that does the same as the original workflow as I don't have any experience with this yet. The original workflow, action.yml and error message can be found below. The original workflow works as intended, but not when executed by the uses keyword.
Original workflow (works as intended):
name: Yaml autosync
description: Auto-sync changes to a template YAML localisation file to all other YAML files in the same directory.
branding:
icon: file-text
color: blue
inputs:
lang_path:
description: 'Path to the folder that contains all lang files'
default: .
required: false
default_file:
description: 'The name of the YAML file that contains all default options. These values are used to fill in any missing info in the other files.'
default: 'default.yml'
required: false
github_token:
description: 'The secret GitHub Token so this action has push access. Make sure to use GitHub secrets and do not push any private info!'
required: true
on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
LANG_PATH: ${INPUT_LANG_PATH}
DEFAULTS: ${INPUT_DEFAULT_FILE}
steps:
- uses: actions/checkout#v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Clone YAML-localisation-sync
run: git clone some_repo
- name: Building the project
run: |
cd YAML-localisation-sync
mvn package
- name: Moving JAR file
run: cp YAML-localisation-sync/target/YamlLocalisation.jar ${LANG_PATH}
- name: Running JAR file
run: |
cd ${LANG_PATH}
java -jar YamlLocalisation.jar ${DEFAULTS}
- name: Repo cleanup
run: |
rm -rf YAML-localisation-sync
cd ${LANG_PATH}
rm YamlLocalisation.jar
- name: Commit changes
run: |
git config --local user.email "41898282+github-actions[bot]#users.noreply.github.com"
git config --local user.name "YAML sync bot"
git add .
git commit -m "Sync YAML localisation files"
git fetch
continue-on-error: true
- name: Push changes
uses: ad-m/github-push-action#master
with:
github_token: ${INPUT_GITHUB_TOKEN}
force: true
Action.yml (workflow above, updated to work as a GitHub Action on the marketplace)
name: Yaml autosync
description: Auto-sync changes to a template YAML localisation file to all other YAML files in the same directory.
branding:
icon: file-text
color: blue
inputs:
lang_path:
description: 'Path to the folder that contains all lang files'
default: .
required: false
default_file:
description: 'The name of the YAML file that contains all default options. These values are used to fill in any missing info in the other files.'
default: 'default.yml'
required: false
github_token:
description: 'The secret GitHub Token so this action has push access. Make sure to use GitHub secrets and do not push any private info!'
required: true
on: [push]
runs:
using: "composite"
env:
LANG_PATH: ${INPUT_LANG_PATH}
DEFAULTS: ${INPUT_DEFAULT_FILE}
steps:
- run: git clone https://github.com/MyProfile/YAML-localisation-sync.git
shell: bash
- run: |
cd YAML-localisation-sync
mvn package
shell: bash
- run: cp YAML-localisation-sync/target/YamlLocalisation.jar ${LANG_PATH}
shell: bash
- run: |
cd ${LANG_PATH}
java -jar YamlLocalisation.jar ${DEFAULTS}
shell: bash
- run: |
rm -rf YAML-localisation-sync
cd ${LANG_PATH}
rm YamlLocalisation.jar
shell: bash
run: |
git config --local user.email "41898282+github-actions[bot]#users.noreply.github.com"
git config --local user.name "YAML sync bot"
git add .
git commit -m "Sync YAML localisation files"
git fetch
shell: bash
continue-on-error: true
Workflow that has the error (in a repo that is used to test the published GitHub action)
name: GitHub Actions
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Yaml autosync
uses: MyProfile/MyRepo#15
with:
github_token: ${secrets.GITHUB_TOKEN}
lang_path: foldertest/
default_file: en.yml
Error message
Current runner version: '2.277.1'
Operating System
Virtual Environment
GITHUB_TOKEN Permissions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout#v2'
Download action repository 'actions/setup-java#v1'
Download action repository 'MyProfile/MyAction#15'
Error: MyProfile/MyAction/15/action.yml (Line: 28, Col: 3): Unexpected value 'steps'
Error: MyProfile/MyAction/15/action.yml (Line: 28, Col: 3): Unexpected value 'steps'
Error: System.ArgumentNullException: Value cannot be null. (Parameter 'You are using a composite action but there are no steps provided in MyProfile/MyAction/15/action.yml.')
at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load MyProfile/MyAction/15/action.yml