Unable to push my storybooks into chromatic - github-actions

I have integrated chromatic into my repository and purpose is to push my storybooks into chromatic.
I have two folder in my repo: 1- backend 2- frontend and I have all storybooks in my frontend folder and my .github/workflows/chromatic.yml file looks like below:
# .github/workflows/chromatic.yml
# Workflow name
name: 'Chromatic'
# Event for the workflow
on: pull_request
# List of jobs
jobs:
chromatic-deployment:
# Operating System
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
# Job steps
steps:
- uses: actions/checkout#v1
with:
fetch-depth: 0
- name: Install dependencies
run: yarn
# 👇 Runs yarn in ./frontend
working-directory: frontend
# 👇 Adds Chromatic as a step in the workflow
- name: Publish to Chromatic
uses: chromaui/action#v1
# Chromatic GitHub Action options
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
workingDir: frontend
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
Is there anything wrong in chromatic.yml file? I have set event on pull request and whenever I create pull request from my branch to another branch(dev) I received notifications that "no job were run" (also attached the screenshot). And when I click "View workflow run" button I got following error:
Error: .github#L1
The job was not started because recent account payments have failed or your spending limit needs to be increased. Please check the 'Billing & plans' section in your settings.
(I have researched this error and also tried different ways as suggested but same issue I am getting).

Related

GitHub Actions - Add Submodule

Problem
I want to be able to add a submodule automatically using GitHub Actions.
I have tried using the following command (since it works fine when run locally on my computer)
name: Trigger to Add New Submodule
on:
repository_dispatch:
types: [ trigger-add-new-submodule ]
jobs:
addSubmodule:
name: Add Submodule
runs-on: [ self-hosted, windows ]
steps:
- name: Checkout
uses: actions/checkout#v3
with:
token: ${{ secrets.MY_TOKEN || secrets.GITHUB_TOKEN }}
submodules: recursive
- name: Pull
run: git pull
- name: Add Submodule
run: git submodule add URL PATH
However, when it is running through the GitHub Actions it appears to have frozen.
I am not sure if it is waiting for user input, or stuck for some other reason.
I used GitHub Hosted instead of self-hosted and got the following output.
fatal: Cannot prompt because user interactivity has been disabled.
bash: line 1: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': No such file or directory
It appears to be an issue with lack of user interactivity.
I am not sure how to allow this, since I cannot use with: token: with run:
Question
Is this even the right way to go about doing this?
I couldn't find any pre-built GitHub Actions to do this, so I figured I should just use the git commands directly.
Is this the correct command to be using, or is there another command that would work better?

When I run a GitHub Action for a feature branch, it reads all files from master instead of reading them from the feature branch

I have a GitHub Action which is set to run at will when triggered manually (with the workflow_dispatch keyword under the on secton). Apparently when I run the Action from a feature branch, it only loads the Action YML from the feature branch and loads everything else from master.
One of the Action's steps calls a PowerShell script. When run for a feature branch, it executes the script that is in master, no the script in my feature branch. If it references a script that only exists in my feature branch and not in master, then it fails and says the script does not exist.
That makes it very hard to experiment with the Action, since apparently all its dependencies need to be merged to master before I can test them.
This is how I trigger my Action:
Go to GitHub -> Actions -> Workflows sidebar and select my workflow.
Next to where it says "This workflow has a workflow_dispatch event trigger", click Run workflow.
Under Use workflow from, select my feature branch.
Click Run workflow.
Am I doing something completely wrong here?
Here is my Action YML:
name: Deploy to persistent environment
on:
workflow_dispatch:
inputs:
deployment_target:
type: choice
description: Choose an environment to deploy to
options:
- dev
- staging
- production
jobs:
deploy-kms-to-persistent-environment:
name: Deploy KMS to ${{ github.event.inputs.deployment_target}}
runs-on: [self-hosted, 3shape-ubuntu-latest]
steps:
- name: Deploy application
working-directory: ./src/deploy/kms-bicep
shell: pwsh
run: |
./deploy-release-application2.ps1
It turns out I need a checkout step in my Action: - uses: actions/checkout#v3
name: Deploy to persistent environment
on:
workflow_dispatch:
inputs:
deployment_target:
type: choice
description: Choose an environment to deploy to
options:
- dev
- staging
- production
jobs:
deploy-kms-to-persistent-environment:
name: Deploy KMS to ${{ github.event.inputs.deployment_target}}
runs-on: [self-hosted, 3shape-ubuntu-latest]
steps:
- uses: actions/checkout#v3
- name: Deploy application
working-directory: ./src/deploy/kms-bicep
shell: pwsh
run: |
./deploy-release-application2.ps1

How to get all the changes of a Pull Request when triggering on pull_request_review?

I currently have a GitHub Action that triggers on:
pull_request_review:
types: [submitted]
I then want to run a command, which expects the contents of changes of the Pull Request.
Previously, I was using
on:
push
and I had no issues with the contents of the files being available in the Action context.
However, my command is failing now, and I think it's because the context only includes the commit that the action was triggered on (no file changes.)
Previously I was running this action on push and that was always successful, with the file changes being available in the context.
I'm using:
steps:
- uses: actions/checkout#v2
(https://github.com/actions/checkout)
Is it possible to use this to have all the file changes on the Pull Request within the Action context?
Any help on this would be appreciated!
You can do that by using an open source Action available on marketplace:
jobs:
build:
runs-on: ubuntu-latest # windows-latest | macos-latest
name: Test changed-files
steps:
- uses: actions/checkout#v2
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files#v14.6
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
The solution above uses git checkout and git diff to get files changed by PR. Alternatively if you really need just information about paths changed and you don't really need files themselves (no checkout) - you can do it without checkout using gh CLI:
gh pr view XXX --json files -q '.files[].path'
You can run it like this:
jobs:
comment:
runs-on: ubuntu-latest
steps:
- run: gh pr view XXX --json files -q '.files[].path'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Does the Github Action checkout#v2 checkout .eslintrc file?

I noticed when I was trying to run my github workflow to deploy my dockerized VUE app to Elastic Beanstalk that I kept getting an error in my logs saying no eslint config found, since I had just a handful of ignore lines.
So when I added a step in the workflow to ls the files being checked out, I saw it did not grab any of the files formatted as .*.
I would assume it should at least be getting the .eslintrc.* file since it is supposed to come featured to run npm install and npm run lint it would look at the checked out config file to determine if the rules pass.
Here is my workflow up to this point:
name: Deploy to Staging Environment
on: [workflow_dispatch]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Latest Repo
uses: actions/checkout#v2
- name: List Checked Out files
run: ls
# DOES NOT SHOW ANY .* files checked out
Is anyone else noticing the same? What should I try?

##[error]No file matched with specific pattern: /appsettings.json

After reading this answer:this
I tried to do the same.
I have a .net core project and in my case, I am using a repo with a publish version so my appsettings.json is in the root of the repo.
# This is a basic workflow to help you get started with Actions
name: DeployToStaging
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
pull_request:
types: [assigned, opened, synchronize, reopened]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
FTP-Deploy-Action:
name: FTP-Deploy-Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2.1.0
with:
fetch-depth: 2
- uses: microsoft/variable-substitution#v1
with:
files: '${{env.DOTNET_ROOT}}/appsettings.json'
env:
ConnectionStrings.ToBudget: 'This is just a test'
- name: FTP Deploy
uses: SamKirkland/FTP-Deploy-Action#3.1.0
with:
ftp-server: <MyServer>
# FTP account username
ftp-username: <MyUsername>
ftp-password: ${{ secrets.FtpPassword }}
So basically I want to transform my connection string (for now it is just a test, in the future I will create a secret) and then push it to the server through FTP.
Everything is working except the variable substitution. The error is: No file matched with specific pattern: /appsettings.json
Any help would be much appreciated
Just found the issue.
instead of files: '${{env.DOTNET_ROOT}}/appsettings.json' I just need to do files: 'appsettings.json'
Now I am having a second issue. SamKirkland/FTP-Deploy-Action#3.1.0 doesn't like the change. It is avoiding uploading because the repo is dirty.
EDIT: regarding the second issue I moved to sebastionpopp/ftpaction