GitHub Actions Failure - Increase NPM Version and Publish - github-actions

I am creating my first NPM packages and working on automating the publish using GitHub Actions. For each commit, I would like to increase the minor version automatically.
If I use npm version minor on the CLI and trigger the GitHub Action, the deployment is completed successfully.
If I try to run the command npm version minor as part of GitHub Action, the deployment is failing at npm publish step.
Workflow File
name: "publish"
on:
push:
branches:
- main
jobs:
release:
name: publish
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout#v3
- name: git configs
run: |
git config user.name nandy
git config user.email nandy#gmail.com
- name: node
uses: actions/setup-node#v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
- run: npm version patch
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
Error Message

Related

Pulling a git submodule with private access from a Github action

I'm trying to pull a git submodule during my 'push' github action. The submodule is a private repository.
I've created a PAT with read-only access to my repositories. And I've added the contents of that PAT as a secret in the git repo (not the submodule).
This is my github action file:
name: Java CI
on: [ push ]
env:
SUBMODULE_ACCESS: ${{ secrets.SUBMODULE_ACCESS }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Update submodules
run: |
git config --global url."https://${SUBMODULE_ACCESS}:x-oauth-basic#github.com/".insteadOf "https://github.com/"
git submodule update --init --recursive
- name: Set up JDK 19
uses: actions/setup-java#v2
with:
java-version: '19'
distribution: 'adopt'
- name: Cache local .m2
uses: actions/cache#v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**.pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run lints and test with Maven
run: mvn clean install -Dall
When I run this, I see the following error:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
But that link just mentions PATs, which I think I've set up?

GitHub Action Vitest CI pipeline

I would like to create a CI pipeline with GitHub Action but I have problems. The front end of the project is developed in Vue 3 and uses vitest to run the tests. It's in a folder called "WEB" in the root directory. So I would like to run my tests at each commit in the master branch but it returns this error:
Error: .github#L1
each step must define a `uses` or `run` key
I used the preexisting "Node.js" template and just added the "working-directory" property to specify the "WEB" folder.
Here is my ".yml" file
name: Runs frontend tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
working-directory: ./WEB
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Execute Unit tests
- run: npm ci
- run: npm run test
When you add a - it add an element at the steps array:
You should do it like this:
- name: Execute Unit tests
run: |
npm ci
npm run test

Github actions release workflow not running for releases created via github actions

We're using changesets action to generate releases and publish to NPM. Here's an example:
Action Log
Release created by that run
The action that I want to run for each release is meant to upload some artifacts.
name: Bundle
on:
release:
types:
- created
- published
- prereleased
- released
jobs:
bundle:
# Prevents changesets action from creating a PR on forks
if: github.repository == 'patternfly/patternfly-elements'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: 16
cache: npm
- name: Install packages
run: npm i --prefer-offline
- name: Dump GitHub Context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Bundle
id: bundle
if: ${{ steps.changesets.outputs.published }}
uses: actions/github-script#v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const workspace = '${{ github.workspace }}';
const bundle = require('./scripts/bundle-release.cjs');
await bundle({ context, github, glob, workspace });
I expected this workflow to run immediately after the changesets publish run, but it did not. In fact it hasn't run once since being added to the repo.
What could be causing this issue?

Github workflows: repsoitory not found in action/checkout section

I'm trying to get my python project to update on Pypi automatically through a github workflow.
I've never done a github workflow (or any workflow). It doesn't seem to work.
It's this line: uses: action/checkout#main under the build-n-publish part.
It always fails and I get: Unable to resolve action action/checkout#main, repository not found.
and this happens no matter what I put in place of main whether it's v1, v2, master, etc...
I couldn't find anything online explaining it. What should I have in place of main?
for context the .yml file:
name: CI
on:
push:
branches:
- main
jobs:
build-n-publish:
name: build and publish pee to pypi
runs-on: macOS-latest
steps:
- uses: action/checkout#pee
with:
repository: ''
- name: Set up Python 3.6
uses: actions/setup-python#v1
with:
python-version: 3.6
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish#master
with:
password: ${{ secrets.pypi_password }}
repository_url: https://pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish#master
with:
password: ${{ secrets.pypi_password }}.

Github Actions - No jobs defined in `jobs`

I have written a simple Github action to check to see if my linting rules have been met whenever a PR is raised. But whenever I run it, I get the error message "No jobs defined in jobs". How can I fix this?
name: Check rules
on:
pull_request:
branches:
- develop
- master
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: '12'
check-latest: true
- run: npm install
- run: npm check-rules
As per the error message, you need to define jobs.
name: Check rules
on:
pull_request:
branches:
- develop
- master
jobs:
your_npm_job_name:
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: '12'
check-latest: true
- run: npm install
- run: npm check-rules