FAIRSPC-23: test outputs (#1454) #4
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
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
# deploy workflow is supposed to be dependent on this one, if you change the name, also change it in deploy.yaml | |
name: Build & Upload Fairspace Docker images | |
env: | |
DOCKER_REGISTRY: ghcr.io | |
#TODO: look for travis and create tickets | |
on: | |
push: | |
branches: | |
- "infra/FAIRSPC-23_github_actions_CI" | |
jobs: | |
# A job to generate one shared unique version tag per build cycle for all built artifacts | |
generate-version: | |
runs-on: ubuntu-latest | |
outputs: | |
output1: ${{ steps.version.outputs.snapshot_version }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- id: version #TODO: introduce release version generation strategy | |
name: Generating version tag for artifacts (Snapshot only) | |
run: | | |
# EXTRACT VERSION | |
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | |
echo "Building images from the branch: $BRANCH" | |
VER=$(cat ./VERSION) | |
echo "Building images of version: $VER" | |
# GET DATE AND TIME FOR VERSIONING | |
DATE=$(date "+%Y%m%d%H%M%S") | |
# DOCKER TAG TO BE ATTACHED (SHARED WITHIN OUTPUT): | |
SNAPSHOT_VERSION=SNAPSHOT-$VER-$DATE | |
echo "snapshot_version=$SNAPSHOT_VERSION" >> "$GITHUB_OUTPUT" | |
echo "Docker tag to be attached to images: $SNAPSHOT_VERSION" | |
build-saturn-service: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Build with Gradle | |
run: ./projects/saturn/gradlew build -p ./projects/saturn/ | |
- name: Upload generated artifacts for further processing | |
uses: actions/upload-artifact@v4 | |
with: | |
name: saturn-build | |
path: ./projects/saturn/build/distributions/*.tar | |
build-mercury-fe-bundle: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Set deployment version | |
run: | | |
sed -i "s/0.0.0-RELEASEVERSION/${{needs.generate-version.outputs.output1}}/g" projects/mercury/package.json | |
- name: Run install | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: install # will run `yarn install` | |
dir: ./projects/mercury/ | |
- name: Build Mercury bundle | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: build # will run `yarn build` | |
dir: ./projects/mercury/ | |
# to be used building an image which includes artifacts of both Pluto and Mercury | |
- name: Upload generated artifacts for further processing | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mercury-build | |
path: ./projects/mercury/build/ | |
- name: Run Mercury tests | |
uses: borales/actions-yarn@v4 | |
with: | |
cmd: test # will run `yarn test` | |
dir: ./projects/mercury/ | |
build-pluto-service: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Build with Gradle | |
run: ./projects/pluto/gradlew build -p ./projects/pluto/ | |
# to be used building an image which includes artifacts of both Pluto and Mercury | |
- name: Upload generated artifacts for further processing | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pluto-build | |
path: ./projects/pluto/build/distributions/*.tar | |
# Pluto .tar file and Mercury bundle run together in one docker container | |
build-and-upload-docker-image-with-pluto-and-mercury: | |
needs: [generate-version, build-mercury-fe-bundle, build-pluto-service] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository # To get Pluto Dockerfile | |
uses: actions/checkout@v4 | |
- name: Download Mercury artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: mercury-build | |
path: ./projects/pluto/build/mercury | |
- name: Download Pluto artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: pluto-build | |
path: ./projects/pluto/build/distributions/ | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/pluto | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./projects/pluto/ | |
push: true | |
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/pluto:${{needs.generate-version.outputs.output1}} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-and-upload-docker-image-for-saturn: | |
needs: [generate-version, build-saturn-service] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository # To get Saturn Dockerfile | |
uses: actions/checkout@v4 | |
- name: Download Saturn artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: saturn-build | |
path: ./projects/saturn/build/distributions/ | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn | |
- name: Build and push Docker image | |
env: | |
SNAPSHOT_VERSION: ${{needs.generate-version.outputs.output1}} | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./projects/saturn/ | |
push: true | |
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn:${{needs.generate-version.outputs.output1}} | |
labels: ${{ steps.meta.outputs.labels }} |