Skip to content

Publish to GCP Artifact Registry (private) #4

Publish to GCP Artifact Registry (private)

Publish to GCP Artifact Registry (private) #4

name: Publish to GCP Artifact Registry (private)
on:
push:
branches:
- main<<<<<<< papercut-deploy-to-private-repo
workflow_dispatch:
inputs:
commit:
description: 'Commit SHA to publish (defaults to last chore(release) commit on the selected branch)'
required: false
type: string
jobs:
publish:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.head_commit.message, 'chore(release)')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check out target commit
if: github.event_name == 'workflow_dispatch'
run: |
if [ -n "${{ inputs.commit }}" ]; then
COMMIT="${{ inputs.commit }}"
echo "Using input commit $COMMIT"
else
COMMIT=$(git log --all --grep='^chore(release)' -n 1 --format='%H')
if [ -z "$COMMIT" ]; then
echo "No chore(release) commit found in repo history"
exit 1
fi
echo "Found last chore(release) commit $COMMIT"
fi
git checkout "$COMMIT"
- uses: actions/setup-node@v4
with:
node-version: '20'
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.NPM_GCLOUD_SERVICE_KEY }}'
- name: Configure npm auth for Artifact Registry
run: |
echo "@skutopia:registry=https://asia-npm.pkg.dev/skutopia/skutopia/" >> ~/.npmrc
- name: Authenticate with private package registry
run: npx --yes google-artifactregistry-auth --repo-config=./.npmrc
- run: npm ci
- run: npm run build
- run: npm publish