Generated txt file not pushing to GitHub repo - java

My question is: I have Maven Project that generates txt file and I'm running it from GitHub Actions. Generated files not pushing into GitHub repo.
Do I need to add some script into yaml?
name: Java CI with Maven
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Set up JDK 11
uses: actions/setup-java#v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean test -DsuiteXMLFILE=testng.xml
These two files not updating at all.
All paths are correct (used relative path).

Related

Docker build stuck in Gradle task

When I try to run this Docker image it stays stuck forever:
FROM gradle:7.4.2-jdk11 as build
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false"
WORKDIR /usr/src/app
COPY . .
RUN ./gradlew shadowJar
FROM adoptopenjdk:latest
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build/libs ./
This is the docker-compose.yml file:
version: "3.8"
services:
slack_bot:
container_name: slack_bot
platform: linux/amd64
build: .
ports:
- "8000:8000"
environment:
PORT: 8000
command: java -jar build/libs/slack-bot-1.0-SNAPSHOT-all.jar
This is the output of docker-compose up (stuck there with the seconds increasing forever):
=> [build 4/4] RUN ./gradlew shadowJar 803.1s
=> => # - Aggregated test and JaCoCo reports
=> => # - Marking additional test source directories as tests in IntelliJ
=> => # - Support for Adoptium JDKs in Java toolchains
=> => # For more details see https://docs.gradle.org/7.4.2/release-notes.html
=> => # To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
=> => # Daemon will be stopped at the end of the build
I tried multiple variations including turning on/off the Docker daemon, different Docker images, increasing JVM memory, etc. without success. I'm using the latest Docker (4.8.2) on an Apple M1. Any hints?

Any changes made by using the GitHub Actions not reflecting into project files(Maven commands)

I'm developing a maven project and using GitHub Actions to build and deploy the package into GitHub. I'm using the maven command to update the version inside the workflow. Here is the workflow
name: Maven Package
on:
push:
branches: ['beta']
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v2
with:
java-version: '11'
distribution: 'adopt'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Semantic Version
run: |
mvn versions:set -DnewVersion=1.3.1-beta
git config remote.origin.url https://github.com/<username>/<repo>.git
git config --global user.name <username>
git config --global user.email <email>
git add -A
git commit -am "version beta update"
- name: Push changes
uses: ad-m/github-push-action#master
with:
github_token: ${{ github.token }}
branch: ${{ github.ref }}
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
when I push the code to the beta branch. My workflow is changing the version and deploying the package, but it's not updating the version inside the pom.xml file. When I execute the command in the terminal it is updating the version inside pom.xml. But when I'm executing it by using Github Actions it is changing the version but not updating the pom file version and also not updating the target file. What should I do?
I need to change the version inside pom.xml using the GitHub-Actions workflow.
Thank you.

buildspec.yml file for Spring Boot project

I have a Spring Boot project named "BikeService". I am generating a war file for this project by using the following command in the pom.xml file
<packaging>war</packaging>
Now I want to deploy this on Elastic Beanstalk which I have creating using
Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.3.6
After uploading the code the deployment is successful and the Health of the environment is OK but on running the environment URL it is showing HTTP 404 - Not Found.
I am using the following buildspec.yml file:
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
pre_build:
commands:
- echo In the pre_build phase...
build:
commands:
- echo Build started on `date`
- mvn install
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- target/bike-service-0.0.1-SNAPSHOT.war
- scripts/*
So the problem was solved after a lot of researching.
The issue was with the buildspec.yml file.
I am posting the correct buildspec.yml file in case anyone searches for it in the future.
The following file if for a Spring Boot project with war packaging.
version: 0.2
phases:
install:
runtime-versions:
java: corretto8
pre_build:
commands:
- echo In the pre_build phase...
build:
commands:
- echo Build started on `date`
post_build:
commands:
- echo Build completed on `date`
- mvn package
- mv target/bike-service-0.0.1-SNAPSHOT.war bike-service-0.0.1-SNAPSHOT.war
artifacts:
files:
- bike-service-0.0.1-SNAPSHOT.war
- .ebextensions/**/*

Dockerfile COPY failed: stat no such file, when using GitHub CI

I am using GitHub Actions for Gradle project with this given steps:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: 11
- run: gradle wrapper
- run: ./gradlew bootJar
- run: ls ./build/libs/
- uses: actions/checkout#v1
- name: Login to docker
run: docker login docker.pkg.github.com -u xxxxxx -p xxxxxx
- uses: actions/checkout#v1
- name: Build the Docker image
run: docker build . -t realtimechat-snapshot-0.$GITHUB_REF
- uses: actions/checkout#v1
- name: Tag the image
run: docker tag realtimechat-snapshot-0.$GITHUB_REF realtimechat-snapshot-0
- uses: actions/checkout#v1
- name: Push the image
run: docker push realtimechat-snapshot-0.$GITHUB_REF
at Build the Docker image step it build this Dockerfile:
FROM alpine:latest
COPY ./build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar
and when it tries to copy the jar file I get this error:
COPY failed: stat
/var/lib/docker/tmp/docker-builder207778036/build/libs/realtimeChattingSystem-0.0.1-SNAPSHOT.jar:
no such file or directory
NOTE*
at - run: ls ./build/libs/ in the steps it actually shows me the jar file:
Run ls ./build/libs/
realtimeChattingSystem-0.0.1-SNAPSHOT.jar
Issue #2
after doing the changes in this post
I faced another issue
this is the steps:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 13
uses: actions/setup-java#v1
with:
java-version: 13
- run: ./gradlew bootJar
- name: Login to Github regestry
run: docker login docker.pkg.github.com -u xxxxx -p xxxxx
- name: Build the Docker image
run: docker build . -t docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.$GITHUB_REF
- name: Push the image to github
run: docker push docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.$GITHUB_REF
At the last step I get this error:
The push refers to repository
[docker.pkg.github.com/sulimanlab/realtime-chat/realtimechat-snapshot-0.refs/heads/master]
3aad04996f8f: Preparing
77cae8ab23bf: Preparing
error parsing HTTP 404 response body: invalid character 'p' after top-level value:
"404 page not found\n"
You only need to use actions/checkout once at the start of your workflow. When you use it again after building I think it's probably resetting your local workspace back to the GITHUB_SHA and your jar file is being deleted in the process.
Try this:
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: 11
- run: gradle wrapper
- run: ./gradlew bootJar
- run: ls ./build/libs/
- name: Login to docker
run: docker login docker.pkg.github.com -u xxxxxx -p xxxxxx
- name: Build the Docker image
run: docker build . -t realtimechat-snapshot-0.$GITHUB_REF
- name: Tag the image
run: docker tag realtimechat-snapshot-0.$GITHUB_REF realtimechat-snapshot-0
- name: Push the image
run: docker push realtimechat-snapshot-0.$GITHUB_REF

How to deploy a maven repository on gitlab to heroku

I created a .gitlab-ci.yml file and tried to deploy my maven repository on gitlab to heroku. Unfortunately I don't understand how to do this without the heroku-cli (which I could not install on gitlab).
The build process and test process is not failing but the deployment process is due to my lack of information about how it exactly works.
The yml file I created looks like this:
before_script:
- apk update && apk add git
- apk update && apk add openjdk8
- apk update && apk add maven
- git --version
build:
stage: build
script:
- mvn compile
test:
stage: test
script:
- mvn test
deploy:
stage: deploy
script:
- heroku git:remote -a NAME_OF_MY_HEROKUAPP
- git push heroku master
only:
- master

Categories

Resources