Migration to jdk21 #223
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: Build | |
concurrency: Testing | |
on: | |
push: | |
branches: [ master, dev ] | |
pull_request: | |
branches: [ master, dev ] | |
env: | |
repository: chat | |
userRepoName: chat | |
onbootJarName: app.jar | |
dockerRepoName: skyere/greencitychat | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 21 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Maven packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Build and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ita-social-projects_GreenCityChat | |
- name: Test Reporter | |
uses: dorny/[email protected] | |
if: success() || failure() | |
with: | |
name: Tests Report | |
path: ${{ env.userRepoName }}/target/surefire-reports/*.xml | |
reporter: java-junit | |
- name: Rename user jar to app | |
run: mv $userRepoName/target/*.jar $userRepoName/target/$onbootJarName | |
- name: Set outputs | |
run: echo "GITHUB_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker images | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: ${{ env.dockerRepoName }}:test-${{ env.GITHUB_SHA_SHORT }} | |
# - name: Kubernetes Set Context | |
# uses: Azure/[email protected] | |
# with: | |
# kubeconfig: ${{ secrets.KUBE_CONFIG }} | |
# - name: Set up Postgres | |
# run: kubectl scale deploy postgres --replicas=1 -n test | |
# | |
# - name: Kubernetes tests | |
# run: | | |
# cd chart-test | |
# go test -v ./... | |
# | |
# - name: Post Set up Postgres | |
# if: success() || failure() | |
# run: kubectl scale deploy postgres --replicas=0 -n test |