Publish Dependencies Image #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Dependencies Image | |
on: | |
workflow_dispatch: | |
inputs: | |
build_secret: | |
type: string | |
description: Build secret | |
push: | |
branches: | |
- deps-image | |
paths-ignore: | |
- '**.md' | |
- '**.txt' | |
- '.**ignore' | |
- 'docs/**' | |
# TODO: what if package.dependencies, files were updated? | |
# this is meant to avoid triggering the on.push event for the version bump | |
- '**package*.json' | |
jobs: | |
check-user-permissions: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check user permission | |
uses: stjude/proteinpaint/.github/actions/check-user-permissions@master | |
with: | |
BUILD_SECRET: ${{ secrets.BUILD_SECRET }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
INPUT_BUILD_SECRET: ${{ github.event.inputs.build_secret }} | |
build: | |
needs: check-user-permissions | |
timeout-minutes: 80 | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PAT }} | |
- name: Login to GitHub Container Registry | |
run: | | |
echo $CR_PAT | docker login ghcr.io -u stjude --password-stdin | |
env: | |
CR_PAT: ${{ secrets.PAT }} | |
# Setup .npmrc file to publish to GitHub Packages | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'npm' | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@sjcrh' | |
- name: Run npm ci | |
run: npm ci | |
- name: Copy serverconfig.json to root | |
run: | | |
cp container/ci/serverconfig.json container/ | |
- name: Create cache folder | |
run: mkdir cache | |
- name: Install xvfb | |
run: sudo apt-get install xvfb | |
- name: TSC | |
run: | | |
cd server | |
npx tsc | |
cd .. | |
- name: Build image | |
run: | | |
npm install glob | |
cd container | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$BRANCH" != "publish-image" && "$BRANCH" != "release-chain" && "$BRANCH" != "master" && ${{ github.event_name }} != "workflow_dispatch" ]]; then | |
echo "skipping build and publishing" | |
else | |
cd deps | |
./version.sh deps | |
./build.sh -m "ghcr.io/stjude/" | |
TAG="$(node -p "require('./package.json').version")" | |
cd .. | |
./run.sh ghcr.io/stjude/ppserver:$TAG | |
sleep 10 | |
cd .. | |
xvfb-run --auto-servernum npm run test:integration | |
HASH=$(git rev-parse --short HEAD 2>/dev/null) | |
docker push ghcr.io/stjude/ppbase:latest | |
docker push ghcr.io/stjude/ppserver:$TAG | |
docker push ghcr.io/stjude/ppfull:$TAG | |
docker push ghcr.io/stjude/ppserver:latest | |
docker push ghcr.io/stjude/ppfull:latest | |
cd container | |
./update_deps_version.sh $TAG ./full/Dockerfile | |
./update_deps_version.sh $TAG ./server/Dockerfile | |
if [[ "$BRANCH" != "master" ]]; then | |
echo "merging to master" | |
git fetch --depth=10 origin master:master | |
git switch master | |
git merge $BRANCH | |
fi | |
git config --global user.email "[email protected]" | |
git config --global user.name "PPTeam CI" | |
git add deps/package.json | |
git add deps/full/Dockerfile | |
git add deps/server/Dockerfile | |
git commit -m "Update deps version to $TAG" | |
git stash -a | |
git pull --rebase | |
git push origin master | |
fi |