Skip to content

Commit 5af4168

Browse files
authored
Merge pull request #470 from Rakshitha650/1.1.5.5
[DSD-931]separated the sonar-analysis and publish-to-nexus
2 parents 59fa8f1 + 050b8cf commit 5af4168

File tree

1 file changed

+115
-16
lines changed

1 file changed

+115
-16
lines changed

.github/workflows/push_trigger.yml

Lines changed: 115 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ on:
1111
- develop
1212

1313
jobs:
14-
1514
build_client:
1615
runs-on: ubuntu-latest
1716
env:
1817
NAMESPACE: mosipdev
1918
SERVICE_NAME: registration-client
2019
SERVICE_LOCATION: registration
21-
2220
steps:
2321
- uses: actions/checkout@v2
2422
- name: Set up JDK 11
@@ -92,17 +90,118 @@ jobs:
9290
docker tag $SERVICE_NAME $IMAGE_ID:$VERSION
9391
docker push $IMAGE_ID:$VERSION
9492
95-
- name: Publish the maven package
96-
run: |
97-
cd registration
98-
mvn deploy -DaltDeploymentRepository=ossrh::default::${{ secrets.RELEASE_URL }} -s $GITHUB_WORKSPACE/settings.xml -f pom.xml
99-
env:
100-
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
101-
GPG_TTY: $(tty)
102-
- name: Analyze with SonarCloud
103-
run: |
104-
cd registration
105-
mvn clean -B verify sonar:sonar -Dsonar.projectKey=${{ secrets.PROJECT_KEY }} -Dsonar.organization=${{ secrets.ORG_KEY }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }}
106-
env:
107-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
93+
publish_to_nexus:
94+
if: "!contains(github.ref, 'master')"
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v2
98+
- name: Set up JDK 11
99+
uses: actions/setup-java@v1
100+
with:
101+
ref: ${{ github.ref }}
102+
java-version: 11
103+
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
104+
settings-path: ${{ github.workspace }} # location for the settings.xml file
105+
106+
- name: Setup branch and env
107+
run: |
108+
# Strip git ref prefix from version
109+
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
110+
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
111+
- name: Setup branch and GPG public key
112+
run: |
113+
# Strip git ref prefix from version
114+
115+
echo ${{ env.BRANCH_NAME }}
116+
117+
echo ${{ env.GPG_TTY }}
118+
sudo apt-get --yes install gnupg2
119+
gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg
120+
gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg
121+
122+
- uses: actions/cache@v1
123+
with:
124+
path: ~/.m2/repository
125+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
126+
restore-keys: |
127+
${{ runner.os }}-maven-${{ env.BRANCH_NAME }}
128+
129+
- name: Setup the settings file for ossrh server
130+
run: echo "<settings> <servers> <server> <id>ossrh</id> <username>${{secrets.RELEASE_USER}}</username> <password>${{secrets.RELEASE_TOKEN}}</password> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>${{secrets.gpg_secret}}</gpg.passphrase> </properties> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>releases-repo</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>staged-releases</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </pluginRepository> </pluginRepositories> </profile> <profile> <id>sonar</id> <properties> <sonar.sources>.</sonar.sources> <sonar.host.url>https://sonarcloud.io</sonar.host.url> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles> </settings>" > $GITHUB_WORKSPACE/settings.xml
131+
132+
- name: Install xmllint
133+
run: |
134+
sudo apt-get update
135+
sudo apt-get install libxml2-utils
136+
- name: Build with Maven
137+
run: |
138+
cd registration
139+
mvn -B -U package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml
140+
- name: Publish the maven package
141+
run: |
142+
cd registration && mvn deploy -DaltDeploymentRepository=ossrh::default::${{ secrets.RELEASE_URL }} -s $GITHUB_WORKSPACE/settings.xml -f pom.xml
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
145+
GPG_TTY: $(tty)
146+
- uses: 8398a7/action-slack@v3
147+
with:
148+
status: ${{ job.status }}
149+
fields: repo,message,commit,workflow,job # selectable (default: repo,message)
150+
env:
151+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
152+
if: failure() # Pick up events even if the job fails or is canceled.
153+
154+
sonar_analysis:
155+
runs-on: ubuntu-latest
156+
env:
157+
NAMESPACE: mosipdev
158+
SERVICE_NAME: registration-client
159+
SERVICE_LOCATION: registration
160+
161+
steps:
162+
- uses: actions/checkout@v2
163+
- name: Set up JDK 11
164+
uses: actions/setup-java@v1
165+
with:
166+
ref: ${{ github.ref }}
167+
java-version: 11
168+
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
169+
settings-path: ${{ github.workspace }} # location for the settings.xml file
170+
171+
- name: Setup branch and env
172+
run: |
173+
# Strip git ref prefix from version
174+
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
175+
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
176+
- uses: actions/cache@v1
177+
with:
178+
path: ~/.m2/repository
179+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
180+
restore-keys: |
181+
${{ runner.os }}-maven-${{ env.BRANCH_NAME }}
182+
- name: Setup the settings file for ossrh server
183+
run: echo "<settings> <servers> <server> <id>ossrh</id> <username>${{secrets.RELEASE_USER}}</username> <password>${{secrets.RELEASE_TOKEN}}</password> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>${{secrets.gpg_secret}}</gpg.passphrase> </properties> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>central</id> <url>https://repo1.maven.org/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> </profile> <profile> <id>sonar</id> <properties> <sonar.sources>.</sonar.sources> <sonar.host.url>https://sonarcloud.io</sonar.host.url> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> </profiles> </settings>" > $GITHUB_WORKSPACE/settings.xml
184+
185+
- name: Install xmllint
186+
run: |
187+
sudo apt-get update
188+
sudo apt-get install libxml2-utils
189+
- name: Build with Maven
190+
run: |
191+
cd registration
192+
mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml
193+
- name: Analyze with SonarCloud
194+
run: |
195+
cd registration
196+
mvn -B -Dgpg.skip verify sonar:sonar -Dsonar.projectKey=mosip_${{ github.event.repository.name }} -Dsonar.organization=${{ secrets.ORG_KEY }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }}
197+
env:
198+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
200+
201+
- uses: 8398a7/action-slack@v3
202+
with:
203+
status: ${{ job.status }}
204+
fields: repo,message,author,ref,job # selectable (default: repo,message)
205+
env:
206+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
207+
if: failure() # Pick up events even if the job fails or is canceled.

0 commit comments

Comments
 (0)