Skip to content

Commit

Permalink
create a release trigger script for the deps image build
Browse files Browse the repository at this point in the history
  • Loading branch information
siosonel committed Oct 21, 2023
1 parent 0a8e419 commit 357c564
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 14 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/CD-publish-deps-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@ on:
type: string
description: Build secret

push:
branches:
- release
- fake-release
- deps-image

jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Check secret
if: github.event_name == 'workflow_dispatch'
run: |
if [ "${{ github.event.inputs.build_secret }}" != "${{ secrets.BUILD_SECRET }}" ]; then
echo "Wrong build secret."
exit 1
fi
- name: Check user permission
if: github.event_name == 'workflow_dispatch'
id: check
uses: scherermichael-oss/action-has-permission@master
with:
Expand All @@ -43,14 +51,28 @@ jobs:
registry-url: 'https://registry.npmjs.org'
scope: '@sjcrh'

- run: |
npm ci
- name: Build image
run: |
# npm ci
cd container/deps
./build.sh -m "ghcr.io/stjude/"
TAG="$(node -p "require('./package.json').version")"
HASH=$(git rev-parse --short HEAD)
docker push ghcr.io/stjude/ppserver:$TAG-$HASH
docker push ghcr.io/stjude/ppfull:$TAG-$HASH
docker push ghcr.io/stjude/ppserver:latest
docker push ghcr.io/stjude/ppfull:latest
./version.sh -c
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" != "release" && ${{ github.event_name != 'workflow_dispatch' }} ]]; then
echo "skipping build and publishing"
else
./build.sh -m "ghcr.io/stjude/"
HASH=$(git rev-parse --short HEAD 2>/dev/null)
TAG="$(node -p "require('./package.json').version")-$HASH"
HASH=$(git rev-parse --short HEAD)
docker push ghcr.io/stjude/ppserver:$TAG-$HASH
docker push ghcr.io/stjude/ppfull:$TAG-$HASH
docker push ghcr.io/stjude/ppserver:latest
docker push ghcr.io/stjude/ppfull:latest
echo "merging to master"
git checkout master
git merge release
git push
fi
18 changes: 18 additions & 0 deletions container/deps/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

ROOTPKGVER=$(node -p "require('../../package.json').version")
SERVERPKGVER=$(node -p "require('../../server/package.json').version")
FRONTPKGVER=$(node -p "require('../../FRONT/package.json').version")

echo "ROOTPKGVER=[$ROOTPKGVER] FRONTPKGVER=[$FRONTPKGVER] SERVERPKGVER=[$SERVERPKGVER]"

npm pkg set version=$ROOTPKGVER
npm pkg set "containerDeps.server"=$SERVERPKGVER
npm pkg set "containerDeps.front"=$FRONTPKGVER

if [[ "$MODE" == "-c" ]]; then
echo "committing version changes"
git add package.json
git commit -m "dep image v$ROOTPKGVER front=$FRONTPKGVER server=$SERVERPKGVER"
# this will trigger the CI-publish-deps-image action
fi
2 changes: 1 addition & 1 deletion container/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (($# < 1)); then
exit 1
fi

echo "[$TPDIR] [$HOSTPORT] [$IMAGE_NAME] [$CONTAINER_NAME]"
echo "[$TPDIR] [$HOSTPORT:$EXPOSED_PORT] [$IMAGE_NAME] [$CONTAINER_NAME]"

#################
# Docker process
Expand Down
4 changes: 2 additions & 2 deletions container/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ WORKDIR /home/root/pp
COPY ./tmppack ./tmppack
WORKDIR /home/root/pp/app/active
# the build script/cmd must be called from the proteinpaint/container dir
RUN npm i --package-lock-only
COPY ./server/package.json ./

RUN npm install --omit=dev
RUN npm ci --omit=dev
COPY ./server/app-server.js ./

EXPOSE 3000
Expand Down
2 changes: 1 addition & 1 deletion rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"dev": "cargo build --release",
"build": "cargo build --release",
"postinstall": "if [ ! -d ./test ]; then cargo build --release; fi",
"postinstall": "if [ ! -d ./test ] & [ ! -d ./target/release ]; then cargo build --release; fi",
"test": "tape **/test/*.spec.js",
"test:unit": "tape **/test/*.unit.spec.js",
"test:integration": "echo 'TODO: rust integration tests'"
Expand Down

0 comments on commit 357c564

Please sign in to comment.