Skip to content

Commit

Permalink
Feature CI (#33)
Browse files Browse the repository at this point in the history
* Test

* Test

* Test

* update scripts
  • Loading branch information
fewensa authored Oct 30, 2024
1 parent 70db2f9 commit f0ed27d
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check Code

on:
push:
branches: [main]
pull_request:
branches: [main]


jobs:
check-code:
name: Check Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install deps
run: yarn install

- name: Build
run: yarn build
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release

on:
push:
tags:
- "v*"
workflow_dispatch:

env:
DOCKER_REGISTRY: ghcr.io

jobs:
release-docker-image:
name: Publish docker image
runs-on: ubuntu-latest
strategy:
matrix:
package:
- reporter
- publisher
steps:
- uses: actions/checkout@v2

- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.DOCKER_REGISTRY }}

- name: Tag
uses: olegtarasov/get-tag@v2.1
- name: Sha
uses: benjlevesque/short-sha@v1.2

- name: Publish docker image
uses: docker/build-push-action@v6
with:
push: true
context: .
file: packages/${{ matrix.package }}-client/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/${{ matrix.package }}:sha-${{ env.SHA }}

- name: Publish docker image with tag
uses: docker/build-push-action@v6
if: startsWith(github.ref, 'refs/tags/v')
with:
push: true
context: .
file: packages/${{ matrix.package }}-client/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/${{ matrix.package }}:${{ env.GIT_TAG_NAME }}
10 changes: 10 additions & 0 deletions packages/publisher-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:20-alpine as builder
ADD . /build
RUN cd /build \
&& yarn install \
&& yarn build:offchain

FROM node:20-alpine
COPY --from=builder /build /app

ENTRYPOINT ["/app/scripts/publisher.entrypoint.sh"]
10 changes: 10 additions & 0 deletions packages/reporter-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:20-alpine as builder
ADD . /build
RUN cd /build \
&& yarn install \
&& yarn build:offchain

FROM node:20-alpine
COPY --from=builder /build /app

ENTRYPOINT ["/app/scripts/reporter.entrypoint.sh"]
9 changes: 9 additions & 0 deletions scripts/publisher.entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
#

set -e

BIN_PATH=$(cd "$(dirname "$0")"; pwd -P)
WORK_PATH=${BIN_PATH}/../

node ${WORK_PATH}/packages/publisher-client/dist/main.js $@
9 changes: 9 additions & 0 deletions scripts/reporter.entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
#

set -e

BIN_PATH=$(cd "$(dirname "$0")"; pwd -P)
WORK_PATH=${BIN_PATH}/../

node ${WORK_PATH}/packages/reporter-client/dist/main.js $@
5 changes: 3 additions & 2 deletions scripts/start-publisher-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ npm run build:offchain

cd ${WORK_PATH}/packages/publisher-client

export XAPI_LOG_LEVEL=debug
export XAPI_REWRITE_CONSOLE=0
export XAPI_LOG_FULL=0
export XAPI_LOG_LEVEL=info
export XAPI_REWRITE_CONSOLE=1

node dist/main.js $@

0 comments on commit f0ed27d

Please sign in to comment.