Consolidate GitHub Actions workflows into a single comprehensive CI/CD pipeline

This commit is contained in:
stabgan
2025-03-27 00:49:05 +05:30
parent 4590590ad0
commit 3f8446a26e

View File

@@ -11,16 +11,23 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: '18' node-version: '18'
cache: 'npm' cache: 'npm'
- name: Configure npm
run: |
npm config set strict-ssl false
npm config set registry https://registry.npmjs.org/
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm cache clean --force && npm install --legacy-peer-deps --no-optional
- name: Build TypeScript - name: Build TypeScript
run: npm run build run: npm run build
@@ -39,16 +46,23 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v4
with: with:
node-version: '18' node-version: '18'
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Configure npm
run: |
npm config set strict-ssl false
npm config set registry https://registry.npmjs.org/
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm cache clean --force && npm install --legacy-peer-deps --no-optional
- name: Download build artifacts - name: Download build artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
@@ -57,40 +71,54 @@ jobs:
path: dist/ path: dist/
- name: Publish to npm - name: Publish to npm
run: npm publish run: npm publish --access=public
env: env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
docker: docker:
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker - name: Extract metadata for Docker
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: stabgandocker/openrouter-mcp-multimodal images: |
stabgandocker/openrouter-mcp-multimodal
ghcr.io/stabgan/openrouter-mcp-multimodal
tags: | tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=sha,format=short
type=ref,event=branch type=ref,event=branch
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v4 uses: docker/build-push-action@v5
with: with:
context: . context: .
push: true push: true
@@ -98,3 +126,9 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
build-args: |
NPM_CONFIG_STRICT_SSL=false
NPM_CONFIG_REGISTRY=https://registry.npmjs.org/
NPM_CONFIG_FETCH_RETRY_MINTIMEOUT=20000
NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT=120000
NODE_ENV=development