-
Notifications
You must be signed in to change notification settings - Fork 10
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
f15f2ed
commit d1d033f
Showing
5 changed files
with
165 additions
and
2 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,64 @@ | ||
name: Build on Push & Pull Request | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
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 | ||
distribution: 'temurin' | ||
|
||
- name: Cache Maven packages | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: maven-settings-xml-action | ||
uses: whelk-io/maven-settings-xml-action@v20 | ||
with: | ||
servers: > | ||
[ | ||
{ | ||
"id": "github-message-rosa", | ||
"username": "${env.GITHUB_USERNAME}", | ||
"password": "${env.GITHUB_TOKEN}" | ||
}, | ||
{ | ||
"id": "github-adapter", | ||
"username": "${env.GITHUB_USERNAME}", | ||
"password": "${env.GITHUB_TOKEN}" | ||
}, | ||
{ | ||
"id": "github-utils", | ||
"username": "${env.GITHUB_USERNAME}", | ||
"password": "${env.GITHUB_TOKEN}" | ||
}, | ||
{ | ||
"id": "github-dao", | ||
"username": "${env.GITHUB_USERNAME}", | ||
"password": "${env.GITHUB_TOKEN}" | ||
} | ||
] | ||
output_file: $GITHUB_WORKSPACE/settings.xml | ||
env: | ||
GITHUB_USERNAME: ${{ secrets.USERNAME }} | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
|
||
- name: Build and analyze | ||
env: | ||
GITHUB_USERNAME: ${{ secrets.USERNAME }} | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
run: | | ||
cat $GITHUB_WORKSPACE/settings.xml | ||
mvn -B verify -s $GITHUB_WORKSPACE/settings.xml -DskipTests | ||
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,29 @@ | ||
name: Docker Build & Push on Tag | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
docker-build-push: | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 40 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Login to DockerHub Registry | ||
run: echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | ||
- name: Set output | ||
id: vars | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | ||
- name: Build the tagged Docker image | ||
env: | ||
RELEASE_VERSION: ${{ steps.vars.outputs.tag }} | ||
run: | | ||
echo $RELEASE_VERSION | ||
echo ${{ steps.vars.outputs.tag }} | ||
docker build . --file Dockerfile --build-arg username=${{ secrets.USERNAME }} --build-arg token=${{ secrets.TOKEN }} --tag samagragovernance/orchestrator:$RELEASE_VERSION | ||
- name: Push the tagged Docker image | ||
env: | ||
RELEASE_VERSION: ${{ steps.vars.outputs.tag }} | ||
run: docker push samagragovernance/orchestrator:$RELEASE_VERSION |
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,38 @@ | ||
# Build stage | ||
FROM maven:3.6.0-jdk-11-slim AS build | ||
ENV HOME=/home/app | ||
RUN mkdir -p $HOME | ||
WORKDIR $HOME | ||
ADD pom.xml $HOME | ||
|
||
# Arguments | ||
ARG username | ||
ARG token | ||
|
||
# Print arguments value | ||
RUN echo $username | ||
RUN echo $token | ||
|
||
# copy settings file to home settings file | ||
COPY /settings.xml $HOME/settings.xml | ||
|
||
# replace username & token in settings file | ||
RUN sed -i "s/USERNAME/$username/g" $HOME/settings.xml | ||
RUN sed -i "s/TOKEN/$token/g" $HOME/settings.xml | ||
RUN cat $HOME/settings.xml | ||
|
||
# Maven package build | ||
RUN mvn -s $HOME/settings.xml dependency:go-offline | ||
|
||
ADD /src $HOME/src | ||
RUN mvn package -s $HOME/settings.xml -DskipTests=true | ||
|
||
# Package stage | ||
FROM openjdk:12-alpine | ||
ENV HOME=/home/app | ||
ENV export $(cat .env | xargs) | ||
WORKDIR $HOME | ||
COPY --from=build $HOME/target/*.jar app.jar | ||
|
||
EXPOSE 8080 | ||
ENTRYPOINT ["java","-jar","app.jar"] |
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,32 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
<servers> | ||
<server> | ||
<id>github</id> | ||
<username>USERNAME</username> | ||
<password>TOKEN</password> | ||
</server> | ||
<server> | ||
<id>github-utils</id> | ||
<username>USERNAME</username> | ||
<password>TOKEN</password> | ||
</server> | ||
<server> | ||
<id>github-message-rosa</id> | ||
<username>USERNAME</username> | ||
<password>TOKEN</password> | ||
</server> | ||
<server> | ||
<id>github-dao</id> | ||
<username>USERNAME</username> | ||
<password>TOKEN</password> | ||
</server> | ||
<server> | ||
<id>github-adapter</id> | ||
<username>USERNAME</username> | ||
<password>TOKEN</password> | ||
</server> | ||
</servers> | ||
</settings> |