Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active December 22, 2023 00:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save YonatanKra/99aa3be8aadad92fc87c9fa39658a718 to your computer and use it in GitHub Desktop.
Save YonatanKra/99aa3be8aadad92fc87c9fa39658a718 to your computer and use it in GitHub Desktop.
Reusable workflows
name: 🏗 Lint & Build
on: workflow_call
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'
- run: npm install
- run: npm run lint
- run: npm run build
name: '🧬 Pre Release'
on:
push:
branches: main
concurrency:
group: ci-pre-release-${{ github.ref }}-1
cancel-in-progress: true
jobs:
call-lint-and-build:
uses: vonage/vivid-3/.github/workflows/_lint-and-build.yml@main
call-unit-tests:
needs: call-lint-and-build
uses: vonage/vivid-3/.github/workflows/_unit-tests.yml@main
call-upload-artifact:
needs: call-unit-tests
uses: vonage/vivid-3/.github/workflows/_upload-artifact.yml@main
call-pre-release:
needs: call-upload-artifact
uses: vonage/vivid-3/.github/workflows/_publish-package.yml@main
with:
version: 3.0.0
name: '📦 Publish Package'
on:
workflow_call:
input:
version:
type: string
required: true
description: Version to bump to
jobs:
release:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download
uses: actions/download-artifact@v2
with:
name: public-artifact
- name: Setup Node.js
# Setup .npmrc file to publish to npm
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
registry-url: 'https://npm.pkg.github.com'
- name: Install
run: npm ci
- name: Bump
env:
short_head: $(git rev-parse --short HEAD)
run: npm version ${{ inputs.version }} --tag latest --no-git-tag-version --no-push
- name: Publish
run: npm publish --access public --tag next --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
name: '🧳 Upload Artifact'
on: workflow_call
jobs:
upload:
name: "Upload Build Artifact"
runs-on: ubuntu-latest
# env:
# GITHUB_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm ci
- run: npm run build
- uses: actions/upload-artifact@v2
if: always()
with:
name: public-artifact
path: |
package.json
package-lock.json
LICENSE.md
dist
.eleventy.js
11ty
if-no-files-found: error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment