build(deps): bump actions/setup-java from 3 to 4 #62
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: Maven Central SNAPSHOT deployment | |
on: | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
env: | |
GHUB_REPO_NAME: fpi-telco-plugin # plugin name | |
SONAR_PROJECT_KEY: vincejv_fpi-telco-plugin | |
jobs: | |
pre_job: | |
name: Duplicate checks | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
paths_result: ${{ steps.skip_check.outputs.paths_result }} | |
steps: | |
- name: Skip duplicate actions | |
id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5 | |
with: | |
concurrent_skipping: outdated_runs | |
cancel_others: true | |
code_quality_checks: | |
name: Code quality checks | |
runs-on: ubuntu-latest | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip != 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
cache: maven | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- 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=${{ env.SONAR_PROJECT_KEY }} -Dsonar.qualitygate.wait=true -P allow-snapshots | |
deploy: | |
name: Release artifact | |
runs-on: ubuntu-latest | |
needs: code_quality_checks | |
outputs: | |
artifact_version: ${{ steps.gen_ver.outputs.artifact_version }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
cache: maven | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Build and release to central repo | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
run: mvn -B deploy -Dlib-only -P release-for-oss,allow-snapshots | |
- name: Store artifact version | |
id: gen_ver | |
run: | | |
echo "artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT | |
pr_update: | |
name: Pull request update | |
if: always() | |
needs: [ pre_job, deploy ] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write # allows job to decorate PRs with analysis results | |
steps: | |
- name: Update PR (Skip message) | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ always() && needs.pre_job.outputs.should_skip == 'true' }} | |
with: | |
message: | | |
⚪ Skipped CI/CD as deployment was done in a previous job | |
- name: Update PR (Success message) | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version != '' }} | |
with: | |
message: | | |
✅ Deployed to DEV environment: `${{ needs.deploy.outputs.artifact_version }}` | |
#### Add to your POM | |
```xml | |
<dependency> | |
<groupId>com.abavilla</groupId> | |
<artifactId>${{ env.GHUB_REPO_NAME }}-lib</artifactId> | |
<version>${{ needs.deploy.outputs.artifact_version }}</version> | |
</dependency> | |
``` | |
- name: Update PR (Failure message) | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version == '' }} | |
with: | |
message: | | |
❌ CI Build & Deployment failed, please check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details |