Use sbt-dynver for versioning #86
Workflow file for this run
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: CI | |
on: | |
workflow_call: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
jobs: | |
front-build: | |
runs-on: ubuntu-latest | |
env: | |
PORT: 3000 | |
APP_ID: mockingbird | |
NODE_ENV: production | |
RELATIVE_PATH: /mockingbird | |
ASSETS_FOLDER_NAME: /assets | |
ASSETS_PREFIX: /mockingbird/assets/ | |
MOCKINGBIRD_API: /api/internal/mockingbird | |
MOCKINGBIRD_EXEC_API: /api/mockingbird/exec | |
DEBUG_PLAIN: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Build | |
run: | | |
cd frontend | |
rm ./env.development.js | |
mkdir -p ./dist/out${ASSETS_FOLDER_NAME} | |
npm install | |
npm run build | |
- name: Copy output | |
run: | | |
cd frontend | |
cp -r ./dist/static${RELATIVE_PATH}/. ./dist/out | |
cp -a ./dist/client/. ./dist/out${ASSETS_FOLDER_NAME} | |
- name: Upload output directories | |
uses: actions/upload-artifact@v3 | |
with: | |
name: front-static | |
path: frontend/dist/out | |
back-build: | |
needs: [front-build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download frontend | |
uses: actions/download-artifact@v3 | |
with: | |
name: front-static | |
path: frontend/dist/out | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 17 | |
check-latest: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
version: '3.20.0' | |
- name: Get the Ref | |
id: get-ref | |
uses: ankitvgupta/[email protected] | |
with: | |
ref: ${{ github.ref }} | |
head_ref: ${{ github.head_ref }} | |
- name: Compile and test | |
run: | | |
cd backend | |
sbt "project mockingbird-api;clean;fixCheck;test;missinglinkCheck;Docker / stage;" | |
- name: ZIP stages files | |
uses: montudor/action-zip@v1 | |
with: | |
args: zip -r layers.zip ./backend/mockingbird-api/target/docker/stage | |
if: ${{ github.ref_type == 'tag' }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./backend/mockingbird-api/target/docker/stage | |
push: true | |
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }} | |
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} | |
- name: Publish layers | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: layers.zip | |
asset_name: layers.zip | |
tag: ${{ github.ref_name }} | |
if: ${{ github.ref_type == 'tag' }} | |
back-build-native: | |
needs: [front-build] | |
runs-on: ubuntu-20.04 | |
env: | |
CI: true | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download frontend | |
uses: actions/download-artifact@v3 | |
with: | |
name: front-static | |
path: frontend/dist/out | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
version: '22.3.1' | |
java-version: '17' | |
components: 'native-image' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'true' | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
version: '3.20.0' | |
- name: Get the Ref | |
id: get-ref | |
uses: ankitvgupta/[email protected] | |
with: | |
ref: ${{ github.ref }} | |
head_ref: ${{ github.head_ref }} | |
- name: Compile and test | |
run: | | |
cd backend | |
sbt "project mockingbird-native;clean;fixCheck;test;GraalVMNativeImage / packageBin;Docker / stage;" | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./backend/mockingbird-native/target/docker/stage | |
push: true | |
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}-native | |
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} |