Skip to content

Migrate to shared-actions v2 #1032

Migrate to shared-actions v2

Migrate to shared-actions v2 #1032

Workflow file for this run

name: Build and Deploy
# Controls when the workflow will run
on:
release:
types:
- created
push:
branches:
- main
pull_request:
branches:
- main
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
java_api_job_build:
name: Build API Job Jar
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Version
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Compile Project
run: ./gradlew service:clean service:compileKotlin --refresh-dependencies
- name: Build Project
run: ./gradlew service:build -Pversion=$VERSION
- name: Upload aggregator-service-job artifact
uses: actions/upload-artifact@v4
with:
name: aggregator-service-job
path: service/build/libs/*.jar
docker_api_job_build:
name: Push to Docker Hub
if: github.event_name == 'release'
needs: java_api_job_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Version
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
IMAGE_ID=figuretechnologies/aggregator-service-job
DOCKER_TAGS=$IMAGE_ID:$VERSION
PRERELEASE=${{ github.event.release.prerelease }}
echo PRERELEASE=$PRERELEASE
if [ "$PRERELEASE" == "false" ]; then
DOCKER_TAGS=$DOCKER_TAGS,$IMAGE_ID:latest
fi
echo "DOCKER_TAGS=$DOCKER_TAGS" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: aggregator-service-job
path: service/build/libs
- name: Log into DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: service
file: service/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}
java_service_build:
name: Build Service Jar
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Version
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Build Project
run: ./gradlew clean build --refresh-dependencies -Pversion=$VERSION
- name: Upload aggregate-service artifact
uses: actions/upload-artifact@v4
with:
name: aggregate-service
path: build/libs/*.jar
docker_service_build:
name: Push to Docker Hub
if: github.event_name == 'release'
needs: java_service_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Version
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
IMAGE_ID=figuretechnologies/aggregate-service
DOCKER_TAGS=$IMAGE_ID:$VERSION
PRERELEASE=${{ github.event.release.prerelease }}
echo PRERELEASE=$PRERELEASE
if [ "$PRERELEASE" == "false" ]; then
DOCKER_TAGS=$DOCKER_TAGS,$IMAGE_ID:latest
fi
echo "DOCKER_TAGS=$DOCKER_TAGS" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: aggregate-service
path: build/libs
- name: Log into DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}
migration_build:
name: Build Migration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Version
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Compile Project
run: ./gradlew migrations:clean migrations:compileKotlin --refresh-dependencies
- name: Build Project
run: ./gradlew migrations:build -Pversion=$VERSION
- name: Upload migration artifact
uses: actions/upload-artifact@v4
with:
name: aggregate-service-migration
path: migrations/build/libs/*.jar
docker_migration_build:
name: Push to Docker Hub
if: github.event_name == 'release'
needs: migration_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Version
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
IMAGE_ID=figuretechnologies/aggregate-service-migration
DOCKER_TAGS=$IMAGE_ID:$VERSION
PRERELEASE=${{ github.event.release.prerelease }}
echo PRERELEASE=$PRERELEASE
if [ "$PRERELEASE" == "false" ]; then
DOCKER_TAGS=$DOCKER_TAGS,$IMAGE_ID:latest
fi
echo "DOCKER_TAGS=$DOCKER_TAGS" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: aggregate-service-migration
path: migrations/build/libs
- name: Log into DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: migrations
file: migrations/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}