Change base image for the Docker builds [2] #15
This file contains hidden or 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: Build (and Publish on tag) | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| build-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout repository | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| # Set up Java 8 for SBT / Scala | |
| - name: Set up Java 8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: zulu | |
| java-version: '8' | |
| cache: sbt | |
| # Set up SBT | |
| - uses: sbt/setup-sbt@v1 | |
| # Set up Node.js 11 | |
| # GitHub runners no longer ship Node 11 by default, so we install it explicitly | |
| - name: Set up Node.js 11 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '11' | |
| cache: 'yarn' | |
| cache-dependency-path: app/frontend/yarn.lock | |
| # Install Yarn 1.x explicitly | |
| - name: Install Yarn | |
| run: | | |
| npm install -g yarn@1.22.19 | |
| yarn --version | |
| # Verify toolchain | |
| - name: Verify tool versions | |
| run: | | |
| java -version | |
| node --version | |
| npm --version | |
| yarn --version | |
| sbt --version | |
| # Build frontend + backend | |
| - name: Build application | |
| run: | | |
| sbt frontendInstallDependencies build | |
| # Upload build artifact (optional but useful) | |
| - name: Upload server package | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vdjdb-server | |
| path: target/universal/*.zip | |
| # ------------------------------- | |
| # Version check (TAG ONLY) | |
| # ------------------------------- | |
| - name: Check numeric version matches sbt version | |
| if: github.ref_type == 'tag' | |
| shell: bash | |
| run: | | |
| set -e | |
| TAG="$GITHUB_REF_NAME" | |
| # Enforce basic tag shape: vX.Y.Z(-anything)? | |
| if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then | |
| echo "Invalid tag format: $TAG" | |
| exit 1 | |
| fi | |
| # Extract numeric core from tag | |
| TAG_NUMERIC=$(echo "$TAG" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | |
| echo "Tag numeric version: $TAG_NUMERIC" | |
| # Extract numeric core from sbt version | |
| SBT_VERSION=$(grep -E '^[[:space:]]*version[[:space:]]*:=.*"' build.sbt \ | |
| | head -n1 \ | |
| | sed -E 's/^[[:space:]]*version[[:space:]]*:= *"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/') | |
| SBT_NUMERIC=$(echo "$SBT_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | |
| echo "sbt numeric version: $SBT_NUMERIC" | |
| if [ "$TAG_NUMERIC" != "$SBT_NUMERIC" ]; then | |
| echo "Numeric version mismatch" | |
| echo "Tag: $TAG_NUMERIC" | |
| echo "sbt: $SBT_NUMERIC" | |
| exit 1 | |
| fi | |
| echo "Numeric versions match" | |
| # ------------------------------- | |
| # Docker publish (TAG ONLY) | |
| # ------------------------------- | |
| - name: Log in to Docker Hub | |
| if: github.ref_type == 'tag' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Publish Docker image | |
| if: github.ref_type == 'tag' | |
| run: sbt Docker/publish |