It has a monorepo, where it will contain two subfolders, which are:
Each with their respective projects and packages. I am trying to access a certain subfolder to do its respective action, but it is giving an error when I run a command to test with lint, which is:
error Couldn't find a package.json file in "/github/workspace"
It probably should not be accessing the frontend subfolder. I need it to run all the commands in this subfolder, how do I do it?
MY .YML:
name: PIPELINE OF TESTS
on:
push:
branches: [frontend-develop, backend-develop]
pull_request_target:
types: [opened, edited, closed]
branches: [main]
jobs:
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
strategy:
matrix:
node-version: [14.x]
architecture: [x64]
steps:
- name: CHECK-OUT GIT REPOSITORY
uses: actions/checkout#v2
- name: USE NODEJS ${{ matrix.node-version }} - ${{ matrix.architecture }}
uses: actions/setup-node#v2
- name: INSTALL PROJECT DEPENDENCIES (YARN)
uses: borales/actions-yarn#v2.0.0
with:
cmd: install
- name: CODE ANALYSE (LINT) AND STYLE-GUIDE ANALYSE (PRETTIER + AIRBNB)
uses: borales/actions-yarn#v2.0.0
with:
cmd: lint-check
- name: UNIT TEST (JEST)
uses: borales/actions-yarn#v2.0.0
with:
cmd: test
Using defaults with run will only be applied to the run step (e.g scripts/commands that you execute yourself and not actions). See the docs:
Provide default shell and working-directory to all run steps in the
job. Context and expression are not allowed in this section.
When you are using a GitHub action (you have uses:) it not possible to change the working directory. Keep in mind that some actions support this - you can pass an additional argument to with:, but in your case borales/actions-yarn do not support that.
What can you do?
As suggested in the borales/actions-yarn REAME.md:
Please keep in mind that this Action was originally written for GitHub Actions beta (when Docker was the only way of doing things).
Consider using actions/setup-node to work with Yarn. This repository will be mostly supporting the existing flows.
You can remove these actions and call yarn directly in run:. Your workflow should look like:
name: PIPELINE OF TESTS
on:
push:
branches: [frontend-develop, backend-develop]
pull_request_target:
types: [opened, edited, closed]
branches: [main]
jobs:
test-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
strategy:
matrix:
node-version: [14.x]
architecture: [x64]
steps:
- name: CHECK-OUT GIT REPOSITORY
uses: actions/checkout#v2
- name: USE NODEJS ${{ matrix.node-version }} - ${{ matrix.architecture }}
uses: actions/setup-node#v2
- name: INSTALL PROJECT DEPENDENCIES (YARN)
run: yarn install
- name: CODE ANALYSE (LINT) AND STYLE-GUIDE ANALYSE (PRETTIER + AIRBNB)
run: yarn lint-check
- name: UNIT TEST (JEST)
run: yarn test
Related
I have a GitHub repo (let's call it my-repo), with GitHub Actions set up and the corresponding .github/workflows/files.yml included, and properly linked to Vercel. When my deployment Action runs, it fails with an HttpError and this log:
Run bobheadxi/deployments#v1
targeting my-GitHub/my-repo
initializing new deployment for develop # refs/heads/develop
unexpected error encountered: HttpError: Not Found
Error: unexpected error encountered: HttpError: Not Found
I have confirmed that refs/heads/develop exists in my-repo's refs.
Here is a screenshot of the GitHub Actions log (with debugging enabled):
Here is my workflow code (Point of failure is Create Deployment):
name: Deploy Environment to Vercel
on:
push:
branches:
- develop
- main
- release
workflow_dispatch:
jobs:
deploy_develop:
name: "Deploy to Develop"
if: github.ref == 'refs/heads/develop'
runs-on: mono-runner
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Create Deployment
uses: bobheadxi/deployments#v1
id: deployment
with:
step: start
token: ${{ secrets.BUILDBOT_PERSONAL_TOKEN }}
env: "Develop"
- name: Vercel Deployment
uses: amondnet/vercel-action#master
id: vercel
with:
vercel-token: ${{ secrets.BUILDBOT_VERCEL_TOKEN }}
github-token: ${{ secrets.BUILDBOT_PERSONAL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: ${{ secrets.VERCEL_ORG_ID }}
- name: Update Deployment
uses: bobheadxi/deployments#v1
if: always()
with:
step: finish
token: ${{ secrets.BUILDBOT_PERSONAL_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
Things I have verified:
Vercel is properly linked to my-repo GitHub project.
GitHub secrets are created to provide the Vercel project ID + org ID (the ones provided in the .vercel directory upon linking the my-repo project to Vercel).
I disabled Vercel builds in my vercel.json file in my-repo so that only GitHub is doing the builds.
The logs don't provide any other information that I can find - any advice would be greatly appreciated!!
The answer ended up being that my secrets were not properly being fed into my GitHub Actions by the Buildbot I have set up. Now that the secrets are properly configured, the same code does deploy to Vercel.
face palm
LOL I had the same problem, here is fix inside workflow file (workflow.yml):
- name: Run worklow
env:
SOME_TOKEN: ${{ secrets.SOME_TOKEN }}
working-directory: ./directory
run: run command
I am trying to restore from a cache. My job reads:
testing-windows:
strategy:
matrix:
example: [Frank2Example1, Frank2Example2, Frank2Example3]
name: Test windows ${{ matrix.example }}
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout#v2
- name: Cache Frank!Runner dependencies - build
uses: actions/cache#v2
with:
path: build
key: ${{ runner.os }}-frank-runner-build
restore-keys: |
${{ runner.os }}-frank-runner-build
- name: Cache Frank!Runner dependencies - download
uses: actions/cache#v2
with:
path: download
key: ${{ runner.os }}-frank-runner-download
restore-keys: |
${{ runner.os }}-frank-runner-download
... Other steps ...
Step Cache Frank!Runner dependencies - build does not find its cache. The output reads:
Run actions/cache#v2
with:
path: build
key: Windows-frank-runner-build
restore-keys: Windows-frank-runner-build
Cache not found for input keys: Windows-frank-runner-build, Windows-frank-runner-build
In this message, the key is duplicated.
This issue does not apply to the next step: Cache Frank!Runner dependencies - download. That step can find its cache.
I tried running this job multiple times. It succeeds, but the cache remains unavailable as mentioned.
My full code is available at https://github.com/mhdirkse/frank-runner, commit SHA ad4644d1ab6b7389294a6ad3d2c67c9655517fa6.
Did I do something wrong or is this a bug in GitHub actions?
EDIT:
As you see in the text, this failure happens on Windows. I am doing the same under Ubuntu, but then there is no error. Both caches work properly under Linux.
EDIT Thursday Agust 11 2022
I am having the same issue under Ubuntu now. On https://github.com/ibissource/frank-manual commit 57b4c937559d20c5420245b3f0c07fa79366c9c6, I have the following GitHub action YAML:
name: TestFrankRunner.
on:
push:
paths: srcSteps/Frank2Webapp/**
pull_request:
paths: srcSteps/Frank2Webapp/**
workflow_dispatch:
jobs:
test-frank2webapp:
name: Test Frank2Webapp
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#v2
- name: Show input
run: echo ${{ github.event.inputs.forceLatestFF }}
- name: Cache Maven downloads
uses: actions/cache#v2
with:
path: ~/.m2/repository/
key: ${{ runner.os }}-maven
restore-keys: |
Linux-maven
- name: Start Frank2Webapp
run: mvn --log-file log.txt clean install jetty:run &
working-directory: srcSteps/Frank2Webapp/v520
...
Other steps
...
My GitHub action log shows the line:
Cache not found for input keys: Linux-maven, Linux-maven
I solved the problem for the example of the frank-manual repository, see EDIT of August 11 2022. In the frank-manual repository, I simply upgraded to actions/cache#v3.
In the release notes of v3, I saw the following:
Fixed tar creation error while trying to create tar with path as ~/ home folder on ubuntu-latest.
Indeed, I was caching directory ~/.m2/repository/ so the fix applies to my test.
I am not sure about the original question that was about the Windows operating system. I hope to inform about that later.
EDIT September 5 2022
The original issue has not been fixed. In project https://github.com/ibissource/frank-runner/, all usages of the cache action have been updated to v3. Nevertheless, step Cache Frank!Runner dependencies - build cannot restore its cache. This problem happens under Windows, no more under Linux.
I am making a custom terraform provider for my organization.
I was following the instructions here:
https://www.terraform.io/registry/providers/publishing?_ga=2.233394398.119722977.1642457969-242172196.1631994131
In the section where it mentions to set up a GitHub Action by copying over the following into my workflows directory:
GitHub Actions workflow from the terraform-provider-scaffolding repository (https://github.com/hashicorp/terraform-provider-scaffolding/blob/main/.github/workflows/release.yml)
Unfortunately doing so seems to have caused the release workflow to no longer work and run. As a result, I was hoping I might get some overall insights into this as I am trying to hook it up to terraform registry and it's not letting me publish it because of a mal-release configuration.
Here is the repo:
https://github.com/Richard-Barrett/terraform-provider-mirantis
Here is the code that I am using for release.yml in my existing workflows:
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout#v2.4.0
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go#v2
with:
go-version: 1.17
-
name: Import GPG key
id: import_gpg
uses: hashicorp/ghaction-import-gpg#v2.1.0
env:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action#v2.8.0
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
I think it may be the way I am auto-tagging in my repo as well, here is what I am using within my tag.yml:
name: 'tag'
on:
push:
branches:
- main
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout#v2.4.0
- name: 'Tag'
uses: anothrNick/github-tag-action#1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Also, the tag workflow wasn't working at first, but now is, but my release status is just showing no status
So after much chagrin and heartache, I found out why it wasn't working.
I didn't specify the Branch on which the action was to be triggered:
Answer:
https://github.com/Richard-Barrett/terraform-provider-mirantis/commit/62a1fb003aee118e133dd22ce79dd488798214e1
The overall change was adding that to the release.yml.
The tag.yml is fine.
As a result, here was the overall change:
name: 'release'
on:
push:
branches:
- main
tags:
- 'v*'
jobs:
And the final release file looked like this:
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: 'release'
on:
push:
branches:
- main
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout#v2.4.0
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go#v2
with:
go-version: 1.17
-
name: Import GPG key
id: import_gpg
uses: hashicorp/ghaction-import-gpg#v2.1.0
env:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action#v2.8.0
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
I am attempting to use GitHub Actions for a complete pipeline, including automatic SemVer versioning (using tags) that I would then like to consume after building my Docker image to tag it with the current version. This is the action that I am using to bump the version, which should have a new_tag output but I cannot reference it, this is what I am trying:
jobs:
setup:
...
version:
needs: [setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/github-tag-action#1.26.0
id: autoversion
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
sonar:
...
anchore:
...
docker:
needs: [setup, version]
steps:
...
- name: Build and push
uses: docker/build-push-action#v2
with:
context: .
push: true
tags: ansfire/flaskql:${{ needs.version.autoversion.outputs.new_tag }}
From what I have read using the needs key is supposed to allow one job to access upstream jobs but I cannot get it to access this. Do I need an outputs key in the version stage? Thanks!
Look into this answer, you need to define the outputs in the job creating the outputs, i.e.
jobs:
version:
[...]
outputs:
new_tag: ${{ steps.autoversion.outputs.new_tag }}
docker:
[...] tags: ansfire/flakql:${{ needs.version.outputs.new_tag }}
My GitHub Action is failing on the final step, creating a pull request.
Below is the section of my yml file that is failing.
pull-request:
needs: regression-tests
name: Development to Master
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
name: checkout
- uses: repo-sync/pull-request#v2
name: pull-request
with:
destination_branch: "master"
pr_title: "Pulling ${{ github.ref }} into master"
pr_body: "*An automated PR test*"
pr_reviewer: "Kev"
pr_draft: true
github_token: ${{ secrets.PullRequest }}
And this is what I see in the log
2021-05-26T10:25:10.0613353Z ##[section]Starting: Request a runner to run this job
2021-05-26T10:25:10.4927450Z Can't find any online and idle self-hosted runner in current repository that matches the required
labels: 'ubuntu-latest'
2021-05-26T10:25:10.4927569Z Can't find any online and idle self-hosted runner in current repository's account/organization that
matches the required labels: 'ubuntu-latest'
2021-05-26T10:25:10.4928148Z Found online and idle hosted runner in current repository's account/organization that matches the required
labels: 'ubuntu-latest'
2021-05-26T10:25:10.6935866Z ##[section]Finishing: Request a runner to run this job
2021-05-26T10:25:18.9831794Z Current runner version: '2.278.0'
2021-05-26T10:25:18.9861037Z ##[group]Operating System
2021-05-26T10:25:18.9862046Z Ubuntu
2021-05-26T10:25:18.9862461Z 20.04.2
2021-05-26T10:25:18.9862889Z LTS
2021-05-26T10:25:18.9863336Z ##[endgroup]
2021-05-26T10:25:18.9864044Z ##[group]Virtual Environment
2021-05-26T10:25:18.9864687Z Environment: ubuntu-20.04
2021-05-26T10:25:18.9865181Z Version: 20210524.1
2021-05-26T10:25:18.9866149Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20210524.1/images/linux/Ubuntu2004-README.md
2021-05-26T10:25:18.9867437Z Image Release: https://github.com/actions/virtual-environments/releases/tag/ubuntu20%2F20210524.1
Any thoughts please on what the issue could be?
This edited code now works
pull-request:
needs: regression-tests
name: Github Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: pull-request
uses: repo-sync/pull-request#v2
with:
destination_branch: "master"
pr_title: "Pulling ${{ github.ref }} into master"
pr_body: "👑 *An automated PR test*"
pr_reviewer: "Kev"
github_token: ${{ secrets.GITHUB_TOKEN }}