Skip to content

Commit

Permalink
Merge pull request #36 from vincejv/development
Browse files Browse the repository at this point in the history
Release to Prod
  • Loading branch information
vincejv authored Oct 19, 2022
2 parents 5dfb6ec + 2d6e132 commit 809dea3
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/pr-reviewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ name: PR Reviewer
on:
issue_comment:
types: [ created, edited ]
inputs: pullRequestNumber
description: Pull request number to auto-approve
required: false
env:
REPOSITORY_OWNER: vincejv
REPOSITORY_BOT: fpibot
jobs:
review:
name: Perform review
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '@fpibot') }}
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, format('@{0}', env.REPOSITORY_BOT)) }}
runs-on: ubuntu-latest
steps:
- name: Approve pull request
if: ${{ github.actor == env.REPOSITORY_OWNER }}
uses: Ana06/automatic-pull-request-review@v0.1.0
uses: hmarr/auto-approve-action@v3
with:
repo-token: ${{ secrets.FPI_BOT_TOKEN }}
event: APPROVE
body: ${{ format('Hi @{0}, your code changes are approved! 🥳', github.actor) }}
allow_duplicate: false
pull-request-number: ${{ github.event.issue.number }}
github-token: ${{ secrets.FPI_BOT_TOKEN }}
review-message: ${{ format('Hi @{0}, your code changes are approved! 🥳', github.actor) }}
146 changes: 146 additions & 0 deletions .github/workflows/release-dev-public.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Maven Central SNAPSHOT deployment

on:
pull_request_target:
types: [ opened, synchronize, reopened ]

env:
SONAR_PROJECT_KEY: vincejv_fpi-framework

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@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v3
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

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@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v3
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 -Prelease-for-oss

- 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: |
✅ Released version to SNAPSHOT repository: `${{ needs.deploy.outputs.artifact_version }}`
#### Parent POM Usage:
```xml
<parent>
<groupId>com.abavilla</groupId>
<artifactId>fpi-framework-pom</artifactId>
<version>${{ needs.deploy.outputs.artifact_version }}</version>
</parent>
```
#### BOM Usage:
```xml
<dependencyManagement>
<dependency>
<groupId>com.abavilla</groupId>
<artifactId>fpi-framework-bom</artifactId>
<version>${{ needs.deploy.outputs.artifact_version }}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencyManagement>
```
- 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
File renamed without changes.

0 comments on commit 809dea3

Please sign in to comment.