Skip to content

Commit

Permalink
Migrate to GitHub Actions (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
brantburnett committed Nov 26, 2023
1 parent 3a87d1f commit bca7fba
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Docker

on:
push:
branches:
- main
tags:
- '*.*.*'
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Get version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Restore
run: npm install

- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Test
run: npm test

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: btburnett3/couchbase-index-manager
- name: Docker Build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Publish to NPM
if: startsWith(github.ref, 'refs/tags/') # Only on tags
run: |
npm run lerna -- version ${{ env.RELEASE_VERSION }} --no-git-tag-version --exact -y &&
pushd packages/couchbase-index-manager && npm publish && popd &&
pushd packages/couchbase-index-manager-cli && npm publish && popd
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16 as build
FROM node:20 as build

WORKDIR /app
COPY ["package*.json", "lerna.json", "./"]
Expand All @@ -8,7 +8,7 @@ RUN npm ci
COPY ./ ./
RUN npm run build

FROM node:16
FROM node:20
LABEL maintainer=bburnett@centeredgesoftware.com
WORKDIR /app
COPY --from=build /app ./
Expand Down

0 comments on commit bca7fba

Please sign in to comment.