Skip to content

Commit

Permalink
Merge pull request #6 from infracloudio/feature/shift
Browse files Browse the repository at this point in the history
Feature/shift
  • Loading branch information
shubhadaR authored Dec 14, 2022
2 parents 8e19f6f + 0a8a1c3 commit 39bceb7
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 23 deletions.
62 changes: 47 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,50 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 14
server-id: github

server-username: GITHUB_USER_REF # env variable name for username

server-password: GITHUB_TOKEN_REF

- name: Check working directory
run: echo "${GITHUB_WORKSPACE}"

- name: Extract Maven project version
run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
id: project

- name: Generate build number
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}

- name: Build project with Maven
run: |
mvn -B package --file pom.xml
mkdir staging && cp target/*.jar staging/
mvn -B package --file pom.xml
mvn -B versions:set -DnewVersion=${{ steps.project.outputs.version }}.${{ steps.buildnumber.outputs.build_number }} -DgenerateBackupPoms=false
mvn deploy
env:

GITHUB_USER_REF: ${{ secrets.GIT_USERNAME }}

GITHUB_TOKEN_REF: ${{ secrets.GIT_TOKEN }}
- name: Test
run: mvn --batch-mode -Dmaven.test.failure.ignore=true test
- name: Test Report
uses: dorny/test-reporter@v1
uses: phoenix-actions/test-reporting@v8
id: test-report
if: success() || failure() # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: target/surefire-reports/TEST-*.xml # Path to test results
reporter: java-junit # Format of test results
fail-on-error: 'false'
- name: Read output variables
run: |
echo "url is ${{ steps.test-report.outputs.runHtmlUrl }}"
Upload_Artifact:

runs-on: ubuntu-latest
Expand All @@ -105,27 +133,23 @@ jobs:
with:
java-version: '11'
distribution: 'adopt'
- run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/jb-hello-world-maven-0.2.0.jar staging
- run: |
mvn --batch-mode --update-snapshots verify
mkdir staging
cp target/hello-world-maven-0.2.jar staging
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: staging/jb-hello-world-maven-0.2.0.jar
files: staging/hello-world-maven-0.2.jar

- name: File exists
if: steps.check_files.outputs.files_exists == 'true'
run: echo "It exists !"
- uses: actions/upload-artifact@v3
with:
name: Package
path: staging
#- name: Temporarily save jar artifact
# uses: actions/upload-artifact@v2
# with:
# name: jar-artifact
# path: ${{ github.workspace }}/target/*.jar
# retention-days: 1
path: staging/*.jar


deploy:
Expand All @@ -136,8 +160,16 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
with:
name: package
path: target/
name: Package
path: staging
# - name: 'Create settings.xml'
# uses: whelk-io/maven-settings-xml-action@v4
# with:
# servers: '[{"id": "github", "password": "${{ secrets.GIT_TOKEN }}"}]'
# - name: Build
# run: |
# mvn dependency:get -DgroupId=inception -DartifactId=hello-world-maven -Dversion=0.2.22 -Dpackaging=jar -DremoteRepositories=https://github.com/infracloudio/CI_GitHub_Actions
# mvn install
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
FROM openjdk:8-jre
ADD target/*.jar /home/myjar.jar
CMD ["java","-jar","/home/myjar.jar"]
ARG FOO=${FOO}

ENV FOO=${FOO}
ADD staging/*.jar /home/myjar.jar
#CMD ["java","-jar","/home/myjar.jar"]
50 changes: 44 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>jb-hello-world-maven</artifactId>
<groupId>inception</groupId>
<artifactId>hello-world-maven</artifactId>
<packaging>jar</packaging>
<version>0.2.0</version>

<version>0.2</version>
<!-- tag::joda[] -->
<scm>
<connection>scm:svn:http://127.0.0.1/dummy</connection>
<developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection>
<tag>HEAD</tag>
<url>http://127.0.0.1/dummy</url>
</scm>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.7</maven.compiler.source>
Expand All @@ -16,7 +21,18 @@
<junit.vintage.version>5.2.0</junit.vintage.version>
<junit.platform.version>1.2.0</junit.platform.version>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<name>inception</name>
<url>https://maven.pkg.github.com/infracloudio/CI_GitHub_Actions</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>github</id>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
Expand All @@ -30,7 +46,6 @@
<version>4.13.1</version>
<scope>test</scope>
</dependency>

</dependencies>
<!-- end::joda[] -->

Expand Down Expand Up @@ -65,6 +80,29 @@
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>buildnumber</id>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<format>{0,number}</format>
<items>
<item>buildNumber</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 39bceb7

Please sign in to comment.