-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sola
committed
Feb 10, 2022
1 parent
bd56903
commit 39abf01
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
name: Build and Release nexusiq-getmetrics | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
env: | ||
IMAGE_NAME: nexusiq-getmetrics | ||
RELEASE_BRANCH: main | ||
RELEASE_VERSION: ${{ github.ref_name }} | ||
|
||
jobs: | ||
|
||
build_application: | ||
name: build nexusiq-getmetrics application | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '8' | ||
distribution: 'adopt' | ||
|
||
- name: Cache Gradle packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew -Pversion=$RELEASE_VERSION clean build packagefiles | ||
|
||
- name: Upload the artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: nexusiq-getmetrics.jar | ||
path: | | ||
build/libs | ||
!build/libs/*plain.jar | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: nexusiq-getmetrics-*.zip | ||
|
||
build_docker_image: | ||
needs: build_application | ||
name: build docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Download the application file | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: nexusiq-getmetrics.jar | ||
|
||
- name: Build image | ||
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | ||
|
||
- name: Log in to registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Use Docker `latest` tag convention | ||
[ "$RELEASE_VERSION" == "$RELEASE_BRANCH" ] && RELEASE_VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo RELEASE_VERSION=$RELEASE_VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$RELEASE_VERSION | ||
docker push $IMAGE_ID:$RELEASE_VERSION | ||