Skip to content

Commit

Permalink
Feature/GitHub actions to publish lock manager image (#11)
Browse files Browse the repository at this point in the history
git workflow for creating pit-lock-manager image and pushing to ghcr.io 
---------

Co-authored-by: Amninder Kaur <[email protected]>
  • Loading branch information
akaur13 and Amninder Kaur authored Jan 17, 2024
1 parent ca0753c commit b8d5d1a
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: build

on: push

jobs:
npm_build:
uses: ./.github/workflows/npm_build.yml
40 changes: 40 additions & 0 deletions .github/workflows/ghcr_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ghcr.io Publish

# when a new release is created or new tag is pushed to master
# tag should be in the format v1.0.0
# v1.0.0-alpha.1 is also valid
# regex to check the tag format
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]'
- 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]+'
- 'v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z]+)+.[0-9]?'

jobs:
build:
uses: ./.github/workflows/npm_build.yml
publish:
runs-on: ubuntu-latest
needs: build
if: needs.build.result == 'success'
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: PATH=$PATH:$(pwd) bin/ubuntu-setup.sh
- run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- run: |
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
- name: Build and publish lock manager image with ver and latest tag
run: sh bin/ghcr-publish.sh lock-manager $RELEASE_VERSION




18 changes: 18 additions & 0 deletions .github/workflows/npm_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# workflow_call to build the rust app
name: npm_build_and_test

on: workflow_call

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
- name: npm install, build and test lock-manager
run: sh bin/npm-build.sh lock-manager
13 changes: 13 additions & 0 deletions bin/ghcr-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e
package_name=$1
version=$2

cd $package_name
tag_with_version=pit-$package_name:$version
tag_ref=ghcr.io/kindredgroup/pit-toolkit/$tag_with_version
echo $tag_ref
docker build . --tag $tag_ref
#for ghcr.io access token mentioned in the github secrets and accessed in actions
docker push $tag_ref
12 changes: 12 additions & 0 deletions bin/npm-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

package_name=$1

echo "Building $package_name"
cd $(pwd)/$package_name
npm ci
npm run build
npm run test
cd ../
4 changes: 4 additions & 0 deletions bin/ubuntu-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

sudo apt-get update && sudo apt-get install -y libsasl2-dev
22 changes: 22 additions & 0 deletions lock-manager/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
LOCAL_HOST_IP=$(ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}')

K8S_NAMESPACE=dev
REGISTRY_URL=ksp
#IMAGE_TAG=$(git rev-parse --short HEAD)
IMAGE_TAG=dev

SERVICE_NAME=lock-manager
SERVICE_PORT=60001

# POSTGRES
PGHOST=$LOCAL_HOST_IP
PGPORT=
PGUSER=
PGPASSWORD=
PGDATABASE=
PGMINPOOLSIZE=10

#DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$PGDATABASE?sslmode=disable

RENEW_BY_IN_SEC=60
ENVIRONMENT=dev

0 comments on commit b8d5d1a

Please sign in to comment.