-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7d5f66f
commit 42bfad4
Showing
5 changed files
with
185 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,54 @@ | ||
# source: https://faun.pub/continuous-integration-of-java-project-with-github-actions-7a8a0e8246ef | ||
name: CI operations PR event DEVELOP branch pipeline | ||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
# Test - Units & Integrations | ||
test: | ||
name: Test - Units & Integrations | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Maven Package | ||
run: mvn -B clean package -DskipTests | ||
#- name: Maven Verify | ||
# run: mvn -B clean verify -Ptest | ||
|
||
# Analyze code with Sonar Cloud | ||
sonar_auth_service: # Generated using Sonar Cloud Maven build template | ||
name: Test - SonarCloud scan (analysis) of auth service | ||
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 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- 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 }} | ||
# -Pdev activate dev profile -f path/to/pom.xml | ||
#run: mvn -Pdev -f -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=DevOps-Nistagram-Organization_Agent | ||
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=DevOps-Nistagram-Organization_Nistagram-admin-service |
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,52 @@ | ||
# source: https://faun.pub/continuous-integration-of-java-project-with-github-actions-7a8a0e8246ef | ||
name: CI operations PUSH event DEVELOP branch pipeline | ||
on: | ||
push: | ||
branches: | ||
- 'develop' | ||
jobs: | ||
# https://github.com/mathieudutour/github-tag-action | ||
prerelease: | ||
name: Create prerelease | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/github-tag-action@v5.6 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create a GitHub prerelease | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
release_name: Prerelease ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
prerelease: true | ||
outputs: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
|
||
artifact: | ||
name: Publish - GitHub Packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Publish artifact on GitHub Packages | ||
run: mvn -B clean deploy -DskipTests | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
docker: | ||
name: Publish - Docker Hub | ||
runs-on: ubuntu-latest | ||
needs: [prerelease] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Build Nistagram Admin service docker image | ||
run: bash ./publish-dockerhub.sh ${{ needs.prerelease.outputs.tag_name }} ${{ secrets.DOCKER_USER }} ${{ secrets.DOCKER_PASS }} |
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,51 @@ | ||
# source: https://faun.pub/continuous-integration-of-java-project-with-github-actions-7a8a0e8246ef | ||
name: CI operations PUSH event MAIN branch pipeline | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
jobs: | ||
# https://github.com/mathieudutour/github-tag-action | ||
release: | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/github-tag-action@v5.6 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create a GitHub release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
release_name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
outputs: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
|
||
artifact: | ||
name: Publish - GitHub Packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Publish artifact on GitHub Packages | ||
run: mvn -B clean deploy -DskipTests | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
docker: | ||
name: Publish - Docker Hub | ||
runs-on: ubuntu-latest | ||
needs: [release] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Build Nistagram Admin service docker image | ||
run: bash ./publish-dockerhub.sh ${{ needs.release.outputs.tag_name }} ${{ secrets.DOCKER_USER }} ${{ secrets.DOCKER_PASS }} |
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
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,14 @@ | ||
#!/bin/bash | ||
|
||
VERSION=${1} | ||
DOCKERHUB_USERNAME=${2} | ||
DOCKERHUB_PASSWORD=${3} | ||
|
||
|
||
ADMIN=${DOCKERHUB_USERNAME}/nistagram-admin-service:${VERSION} | ||
|
||
DOCKER_BUILDKIT=1 docker build -t ${ADMIN} --no-cache . | ||
|
||
docker login --username ${DOCKERHUB_USERNAME} --password ${DOCKERHUB_PASSWORD} | ||
|
||
docker push ${ADMIN} |