Skip to content

prototype dist tarball generation #140

prototype dist tarball generation

prototype dist tarball generation #140

Workflow file for this run

name: Publish
on:
push:
branches:
- "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: holusion/e-corpus
DEPLOY_HOST: ecorpus.holusion.com
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
build-ui:
name: Build UI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: install voyager dependencies
run: (cd source/voyager && npm ci --legacy-peer-deps)
- name: install ui dependencies
run: npm ci && (cd source/ui && npm ci)
- name: build UI
run: npm run build-ui
- uses: actions/upload-artifact@v4
with:
name: "client"
path: "dist"
if-no-files-found: error
retention-days: 1
build-server:
name: Build Server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: install
run: npm ci && (cd source/server && npm ci)
- name: test
run: (cd source/server && npm test)
- name: build
run: npm run build-server
- uses: actions/upload-artifact@v4
with:
name: "server"
path: "source/server/dist"
if-no-files-found: error
retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: "server-files"
path: |
source/server/package.json
source/server/package-lock.json
source/server/migrations/
source/server/templates/
source/server/LICENSE.md
retention-days: 1
pack:
name: Pack tarball
runs-on: ubuntu-latest
needs: [build-ui, build-server]
steps:
- uses: actions/download-artifact@v4
with:
path: eCorpus
- name: edit run scripts
working-directory: eCorpus
run: |
jq '.scripts.start ="node server/index.js"' ./server-files/package.json > "package.json"
rm server-files/package.json
mv server-files/* ./
rm -r server-files
- name: make tarball
run: |
tar -zcf eCorpus-${{github.ref_name}}.tgz eCorpus
- uses: actions/upload-artifact@v4
with:
name: "dist"
path: "eCorpus-*.tgz"
if-no-files-found: error
retention-days: 10
docker-publish:
name: Docker Image
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
digest: ${{ steps.push.outputs.digest }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
id: push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
deploy:
name: Deploy (ecorpus.holusion.com)
runs-on: ubuntu-latest
environment: ecorpus.holusion.com
needs: [docker-publish]
steps:
- name: set up ssh configuration
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p "$HOME/.ssh"
echo "$PRIVATE_KEY" > "$HOME/.ssh/id_ed25519"
chmod 600 "$HOME/.ssh/id_ed25519"
ssh-keyscan -t rsa ${{ env.DEPLOY_HOST }} > "$HOME/.ssh/known_hosts"
- name: Log in to the Container registry
# seems required even if image is public for unclear reasons
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: update docker service
run: >
docker -H ssh://github@${{ env.DEPLOY_HOST }}:22 service update
--with-registry-auth
--image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.docker-publish.outputs.digest }}
ecorpus_main
- name: check service status
run: >
curl -sSL --fail -H "Accept: application/json" -I http://${{ env.DEPLOY_HOST }}/api/v1/scenes