lerna publish not working in GitHub Actions - github-actions

We have a monorepo that we are using Lerna to publish to a private package manager (nexus). When the action runs, it fails with same vague message:
info cli using local version of lerna
lerna notice cli v5.3.0
lerna info ci enabled
Error: Process completed with exit code 1.
This message occurs after github actions tries to run the lerna publish command.
I've tried dozens of variations of installing Lerna globally and locally as well as all sort of variations of flags on my lerna bootstrap and lerna publish commands. I am not sure what to try. Any insights would be appreciated. Below is my worklflow file.
Node: 16.15.1
Lerna: 5.3.0
release.yml
name: 'MyPackage Production Release'
on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: Which version should be published?
options:
- patch
- minor
- major
tag:
required: true
type: choice
description: Which npm tag should this be published to?
options:
- latest
- next
- test
jobs:
build-my-package:
runs-on: [self-hosted, Linux, X64, enterprise]
steps:
- uses: actions/checkout#v3
with:
fetch-depth: 0 #indicates all history for all branches and tags.
- uses: actions/setup-node#v3
with:
node-version: 16.15.1
registry-url: 'https://registry.npmjs.org'
- name: Configure Identity
run: |
git config user.name github-actions
git config user.email github-actions#github.com
shell: bash
- name: strict SSL
run: |
npm config set cafile my-file.pem
npm config set strict-ssl false
npm config set https-proxy http://proxy.our.proxysite.net:80/
npm config set proxy http://proxy.our.proxysite.net:80/
npm config set NODE_TLS_REJECT_UNAUTHORIZED=0
npm config set registry https://registry.npmjs.org/
- name: Install Dependencies
run: |
npm ci --no-package-lock --legacy-peer-deps
lerna bootstrap --ignore-scripts -- --legacy-peer-deps
shell: bash
- name: Prepare Nexus Token
run: |
npm config set registry https://nexus.our.site.net/repository/my-package-repo/
npm config set email myemail#myemail.net
npm config set strictSSL false
npm config set alwaysAuth true
echo //nexus.our.site.net/repository/my-package-repo/:_auth=${{ secrets.NEXUS_BASE64_AUTH }} > .npmrc
npm config set _auth ${{ secrets.NEXUS_BASE64_AUTH }}
shell: bash
- name: Release
run: |
HUSKY_SKIP_HOOKS=1 lerna publish $(echo "${{ github.event.inputs.version }}") --yes --force-publish='*' --dist-tag $(echo "${{ github.event.inputs.tag }}") --conventional-commits --create-release github
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GHE_API_URL: ${{ secrets.GHE_API_URL }}
GHE_VERSION: ${{ secrets.GHE_VERSION }}
shell: bash

Related

GitHub Actions deploy a react + express app to AWS Elastic Beanstalk

I'm trying to set up a deployment using GitHub actions. Build the React app and use express to serve it.
name: EB Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
steps:
- uses: actions/checkout#v2
- name: Set up Python 3.9
uses: actions/setup-python#v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install awsebcli
- uses: actions/setup-node#v2
with:
node-version: '16'
- name: Deploy to Elastic Beanstalk
run: |
cd client
npm i
npm run build
mv dist ..
cd ..
eb deploy
app.use(express.static(path.join(__dirname, './dist')))
Everything works fine except eb doesn't deploy dist folder.
Even when I run eb labs download to download the deployed version I don't see dist folder in the zip file.
I ended up zipping the whole dir and eb deploy --staged it, for it to work.
I guess eb was ignoring the dist folder because it wasn't being tracked by git. I added these commands:
git config --global user.email "GH-DEPLOY#aws.null"
git config --global user.name "GH-DEPLOY"
git add dist
git commit -m 'add react app'
eb deploy --staged

running gui application on github hosted runner

for testing purposes, is it possible to run GUI applications on GitHub-hosted runners?
I tried to run Windows Calculator (Microsoft.WindowsCalculator_8wekyb3d8bbwe!App) on "windows-2022" via WinAppDriver and it fails with "WebDriverException: Package was not found".
Any suggestion(s)?
TIA,
Adrian.
P.S. here is my GitHub Actions workflow for the above:
# ISSUE fails with WebDriverException: Package was not found
# see https://github.com/QA-Automation-Starter/qa-automation/actions/runs/3234841483/jobs/5298454871
build-and-test-on-windows:
name: windows build&test
# see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
runs-on: windows-2022
environment: development
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
settings-path: ${{ github.workspace }}
# ISSUE somehow should run WinAppDriver
# see https://github.com/microsoft/WinAppDriver/issues/1722
# and https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md
# TODO maybe, should re-publish the site from here (?)
- run: |
choco install -y autologon
autologon %USERNAME% $USERDOMAIN%
start cmd /c "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"
cd qa-testing-example
mvn install ^
-s %GITHUB_WORKSPACE%\settings.xml ^
-Pmode-build-fast,mode-build-quiet,environment-default,testing-windows,device-windows
shell: cmd

Environment variables when deploying Firebase Cloud functions with Github Actions

I have been trying to automate the deployment of firebase cloud functions using the Github actions CI/CD workflows.
The functions are developed using NodeJs, Express, and Typescript. And all environment variables are saved in a .env file that is not tracked on github (for obvious reasons)
The main.yaml file (in .github/workflows/)
name: CI/CD
on:
push:
branches: [ deploy ]
pull_request:
branches: [ deploy ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: create env file
run: |
cd functions
touch .env
echo "${{ secrets.ENV_VARS }}" >> .env
- name: Install npm packages
run: |
cd functions
npm install
- name: Deploy to Firebase
uses: w9jds/firebase-action#master
with:
args: deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
The workflow first creates a .env file where it writes the env variables (saved in github secrets)
then installs the dependencies,
and finally deploy the cloud functions
The steps are executed without any issues, up to the deployment part where I got this error
Error: Service account object must contain a string "project_id" property.
at FirebaseAppError.FirebaseError [as constructor] (/github/workspace/functions/node_modules/firebase-admin/lib/utils/error.js:44:28)
at FirebaseAppError.PrefixedFirebaseError [as constructor] (/github/workspace/functions/node_modules/firebase-admin/lib/utils/error.js:90:28)
at new FirebaseAppError (/github/workspace/functions/node_modules/firebase-admin/lib/utils/error.js:125:28)
at new ServiceAccount (/github/workspace/functions/node_modules/firebase-admin/lib/credential/credential-internal.js:134:19)
at new ServiceAccountCredential (/github/workspace/functions/node_modules/firebase-admin/lib/credential/credential-internal.js:68:15)
at Object.exports.cert (/github/workspace/functions/node_modules/firebase-admin/lib/credential/credential.js:34:54)
at Object.<anonymous> (/github/workspace/functions/lib/config/firebase.js:10:34)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
Thank you in advance
I solved this problem. The answer was very simple: instead of following the different tutorials that use "w9jds/firebase-action#master" for the deployment, I simply used firebase deploy :)
The new main.yaml
name: CI/CD
on:
push:
branches: [ deploy]
pull_request:
branches: [ deploy]
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
# Environment variables
- name: create env file
run: |
cd functions
touch .env
echo "${{ secrets.ENV_VARS }}" >> .env
# Install npm packages and firebase
- name: Install npm packages
run: |
cd functions
npm install
npm audit fix
npm install firebase-tools
# Run tests
- name: Run tests
run: |
cd functions
npm run test
# Deploying the functions to firebase
- name: Deploy to Firebase
run: |
cd functions
npm run deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

composite github action, automatically cd into actions directory?

I am trying to setup a github actions bot that uses composite to build when the action runs. Notably, this isn't required, and I know that ncc would also achieve the same thing, but I'm curious if it's possible to make this work in a sustainable way.
For some context, I'm trying to run my alita-moore/EIP-Bot private action with the yaml script being...
name: "Auto Merge EIP"
description: "A bot that lints EIP edits, finds common errors, and can auto-merge"
inputs:
GITHUB-TOKEN:
description: |-
The Github token to be used by this bot when merging, posting comments, or requesting reviewers
required: true
VERSION:
description: version of the action; this is required because of how actions work
required: true
runs:
using: "composite"
steps:
- run: cd /home/runner/work/_actions/alita-moore/EIP-Bot/${{ inputs.VERSION }} && npm ci && npm run build && GITHUB_TOKEN=${{ inputs.GITHUB-TOKEN }} node build/index.js
shell: bash
And this currently runs with a given repo's workflow yaml being
on: [pull_request]
jobs:
auto_merge_bot:
runs-on: ubuntu-latest
name: EIP Auto-Merge Bot
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup Node.js Enviornment
uses: actions/setup-node#v2
with:
node-version: '14'
- name: auto-merge-bot
uses: alita-moore/EIP-Bot#1.0.8
id: auto-merge-bot
with:
GITHUB-TOKEN: ${{ secrets.TOKEN }}
VERSION: 1.0.8
You may have noticed that before the npm ci && npm run build I first had to cd /home/runner/work/_actions/alita-moore/EIP-Bot/${{ inputs.VERSION }}
If you don't do this it'll throw the following error
Run alita-moore/EIP-Bot#1.0.1
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/EIPs/EIPs/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/EIPs/EIPs/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-03-14T09_02_26_002Z-debug.log
Error: Process completed with exit code 254.
Is there a better way to do this?
You can use ${{github.action_path}} for the path of the directory containing the action definition file action.yaml:
[...]
runs:
using: "composite"
steps:
- run: cd ${{github.action_path}} && npm ci && npm run build && GITHUB_TOKEN=${{ inputs.GITHUB-TOKEN }} node build/index.js
shell: bash
github.action_path | string | The path where your action is located. You can use this path to easily access files located in the same repository as your action. This attribute is only supported in composite run steps actions.
https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
The value for ${{ github.action_path }} is also available by default as the environment variable GITHUB_ACTION_PATH, so something like this is also an option:
[...]
- uses: actions/setup-python#v4
with:
python-version: '3.9'
- name: install-dependencies
run: pip install -r $GITHUB_ACTION_PATH/requirements.txt
shell: bash
This assumes the requirements.txt file is at the root of my composite actions 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