Publish Npm Package to JFrog artifactory using Github action - github-actions

How can I publish Npm Package to custom JFrog artifactory using Github action?
publish:
name: Publish the Packages
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: ${{ env.ARTIFACTORY_URL }}
- name: Publish Packages
run: npm publish
working-directory: ${{ env.CORE_WORKING_DIR }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
The above one is giving 401 error. Is it the right approach to do or we've to use some third party actions?

From what I can find, you'll have to do this in a more manual fashion by setting up the JFrog CLI in GitHub.
First, set up JFrog in GitHub actions: https://github.com/marketplace/actions/setup-jfrog-cli
Then, go to JFrog and find how to install npm packages to artifactory using their CLI: https://jfrog.com/blog/npm-flies-with-jfrog-cli/
- uses: jfrog/setup-jfrog-cli#v2
env:
# JFrog platform url (for example: https://acme.jfrog.io)
JF_URL: ${{ secrets.JF_URL }}
# Basic authentication credentials
JF_USER: ${{ secrets.JF_USER }}
JF_PASSWORD: ${{ secrets.JF_PASSWORD }}
or
# JFrog Platform access token
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- run: |
jf rt npm-install --build-name=${{ inputs.build_name }} --build-number=${{ inputs.build_number }}
That's roughly how it should work.

Related

how can i run oc login and oc rollout using github action?

here are my some of the workflow steps and last one is failing
- name: Install oc
uses: redhat-actions/openshift-tools-installer#v1
with:
oc: 4.10
# https://github.com/redhat-actions/oc-login#readme
- name: Log in to OpenShift
uses: redhat-actions/oc-login#v1
with:
openshift_server_url: ${{ env.OPENSHIFT_SERVER }}
openshift_token: ${{ env.OPENSHIFT_TOKEN }}
insecure_skip_tls_verify: true
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
- name: Deploy new image as rollout
run: oc rollout latest dc/asenion-app
unable to find out any GitHub action in github marketplace to run "oc rollout" or other openshift cli commands

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?

How to deploy GitHub Action for my KMM project

Currently, I got some problems when I try to write the YAML file for deploying the GitHub action for KMM project. I don't know how to write the correct script (gradlew command) about testing the code of the shared module. Here's a part of my YAML file:
test_job:
name: Test
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v2
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action#e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Restore Cache
uses: actions/cache#v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradle executable
run: chmod +x ./gradlew
- name: Run Debug Tests
run: ./gradlew testDebugUnitTest --continue
- name: Upload Test Reports
if: ${{ always() }}
uses: actions/upload-artifact#v2
with:
name: test-reports
path: '**/build/reports/tests/'
You can use:
./gradlew check to run tests for all your targets
./gradlew <targetName>Test to run it for a specific target
Note that probably you'd want to specify the shared module as well, for ex: ./gradlew :shared:check
For more information you could check out: https://kotlinlang.org/docs/mpp-run-tests.html#run-tests-for-one-or-more-targets

Getting an error while setting up yml file in GitHubActions

I am going through a course and I am getting a syntax error on the second last line below (shell: bash). Any ideas? If I remove that line I get the same error on the next line (run: npm ci).
name: Build, test, & deploy
on: [push]
jobs:
build:
name: Project build & package
if: "!contains(github.even.head_commit.message, '[skip-ci]'"
runs-on: ubuntu-latest
steps:
-name: checkout repo action
uses: actions/checkout#master
-name: Setup Node v10.x
uses: actions/setup-node#v1
with:
node-version:10.x
-name: Cache Node.js packages
uses: actions/cache#v1
env:
cache-name: cache-node-packages
with:
#use `~/npm` for macOS / Linux agents
# & '%AppData%/npm-cache' for Windows agents
path: ~./npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
-name: Resolve project dependencies with NPM
shell: bash
run: npm ci
The biggest problems were spacing and indentation. I also had a missing paren.
name: Build, test, & deploy
on: [push]
jobs:
build:
name: Project build & package
if: "!contains(github.even.head_commit.message, '[skip-ci]')"
runs-on: ubuntu-latest
steps:
- name: checkout repo action
uses: actions/checkout#master
- name: Setup Node v10.x
uses: actions/setup-node#v1
with:
node-version: 10.x
- name: Cache Node.js packages
uses: actions/cache#v1
env:
cache-name: cache-node-packages
with:
#use `~/npm` for macOS / Linux agents
# & '%AppData%/npm-cache' for Windows agents
path: ~./npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Resolve project dependencies with NPM
shell: bash
run: npm ci

How to trigger gh-pages branch changes via another action

I got this action which publishes to gh-pages successfully :
name: Deployment
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout#v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Packages
run: npm install
- name: Build page
run: npm run build
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages#v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./build
I added second action
name: S3Publish
on:
push:
branches:
- gh-pages
... but it never triggers
We can also put .github directory including your second workflow to the gh-pages branch.
- name: Deploy
uses: peaceiris/actions-gh-pages#v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # Recommended
personal_token: ${{ secrets.PERSONAL_TOKEN }} # An alternative
# github_token: ${{ secrets.GITHUB_TOKEN }} # Dot not use this token for this case.
exclude_assets: ''
Set exclude_assets to empty for including the .github directory to deployment assets.
For more details, see the latest README: How to trigger gh-pages branch changes via another action - Stack Overflow