-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2403 from tawoe/develop
Container build on Pull Request / Downloadable .war artifact
- Loading branch information
Showing
8 changed files
with
345 additions
and
51 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,9 @@ | ||
FROM jetty:9.4-jdk11-alpine | ||
|
||
# Copy OBP source code | ||
# Copy build artifact (.war file) into jetty from 'maven' stage. | ||
COPY /jmx_prometheus_javaagent-0.20.0.jar /var/lib/jetty/jmx_prometheus_javaagent-0.20.0.jar | ||
COPY /.github/jmx_exporter.config /var/lib/jetty/prometheus_config.yml | ||
COPY /obp-api/target/obp-api-1.*.war /var/lib/jetty/webapps/ROOT.war | ||
|
||
CMD ["java -jar $JETTY_HOME/start.jar -javaagent:$JETTY_BASE/jmx_prometheus_javaagent-0.20.0.jar=8090:$JETTY_BASE/prometheus_config.yml"] |
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,81 @@ | ||
name: Build and publish container develop | ||
|
||
# read-write repo token | ||
# access to secrets | ||
on: | ||
workflow_run: | ||
workflows: [build maven artifact] | ||
branches: | ||
- develop | ||
types: | ||
- completed | ||
|
||
env: | ||
## Sets environment variable | ||
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }} | ||
DOCKER_HUB_REPOSITORY: obp-api | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "push" | ||
})[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/push.zip', Buffer.from(download.data)); | ||
- run: unzip push.zip | ||
|
||
- name: prepare the artifact | ||
run: | | ||
mkdir -p obp-api/target/ | ||
cp obp-api-1.10.1.war obp-api/target/obp-api-1.10.1.war | ||
- name: Build the Docker image | ||
run: | | ||
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io | ||
docker build . --file .github/Dockerfile_PreBuild --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop | ||
docker build . --file .github/Dockerfile_PreBuild_OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA-OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest-OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop-OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:${GITHUB_REF##*/}-OC | ||
docker push docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }} --all-tags | ||
echo docker done | ||
- uses: sigstore/cosign-installer@main | ||
|
||
- name: Write signing key to disk (only needed for `cosign sign --key`) | ||
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key | ||
|
||
- name: Sign container image | ||
run: | | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop-OC | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest-OC | ||
env: | ||
COSIGN_PASSWORD: "${{secrets.COSIGN_PASSWORD}}" | ||
|
||
|
||
|
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,82 @@ | ||
name: Build and publish container non develop | ||
|
||
# read-write repo token | ||
# access to secrets | ||
on: | ||
workflow_run: | ||
workflows: [build maven artifact] | ||
branches: | ||
- '*' | ||
- '!develop' | ||
types: | ||
- completed | ||
|
||
env: | ||
## Sets environment variable | ||
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }} | ||
DOCKER_HUB_REPOSITORY: obp-api | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "push" | ||
})[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/push.zip', Buffer.from(download.data)); | ||
- run: unzip push.zip | ||
|
||
- name: prepare the artifact | ||
run: | | ||
mkdir -p obp-api/target/ | ||
cp obp-api-1.10.1.war obp-api/target/obp-api-1.10.1.war | ||
- name: Build the Docker image | ||
run: | | ||
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io | ||
docker build . --file .github/Dockerfile_PreBuild --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop | ||
docker build . --file .github/Dockerfile_PreBuild_OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA-OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest-OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop-OC --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:${GITHUB_REF##*/}-OC | ||
docker push docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }} --all-tags | ||
echo docker done | ||
- uses: sigstore/cosign-installer@main | ||
|
||
- name: Write signing key to disk (only needed for `cosign sign --key`) | ||
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key | ||
|
||
- name: Sign container image | ||
run: | | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop-OC | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest-OC | ||
env: | ||
COSIGN_PASSWORD: "${{secrets.COSIGN_PASSWORD}}" | ||
|
||
|
||
|
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,57 @@ | ||
name: Build and publish commiter container | ||
|
||
# read-write repo token | ||
# access to secrets | ||
on: | ||
workflow_run: | ||
workflows: [Build on Pull Request] | ||
types: | ||
- completed | ||
|
||
env: | ||
## Sets environment variable | ||
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }} | ||
|
||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "pr" | ||
})[0]; | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
var fs = require('fs'); | ||
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); | ||
- run: unzip pr.zip | ||
- name: Get user from file | ||
run: echo "USER_NAME=$(cat UN)" >> $GITHUB_ENV | ||
|
||
- name: prepare the artifact | ||
run: | | ||
mkdir -p obp-api/target/ | ||
cp obp-api-1.10.1.war obp-api/target/obp-api-1.10.1.war | ||
- name: Build the Docker image | ||
run: | | ||
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io | ||
docker build . --file .github/Dockerfile_PreBuild --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/obp-api-${{ env.USER_NAME }}:$GITHUB_SHA --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/obp-api-${{ env.USER_NAME }}:latest | ||
docker push docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/obp-api-${{ env.USER_NAME }} --all-tags | ||
echo docker done |
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,96 @@ | ||
name: Build and publish jmx container develop | ||
|
||
# read-write repo token | ||
# access to secrets | ||
on: workflow_dispatch | ||
|
||
env: | ||
## Sets environment variable | ||
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }} | ||
DOCKER_HUB_REPOSITORY: obp-api | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
var matchRun = workflowRuns.data.workflow_runs.filter((run) => { | ||
return run.head_sha == context.sha | ||
var workflowRuns = await github.actions.listWorkflowRunsForRepo({ | ||
})[0]; | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
var matchRun = workflowRuns.data.workflow_runs.filter((run) => { | ||
return run.head_sha == context.sha | ||
})[0]; | ||
run_id: matchRun.id, | ||
}); | ||
if (!matchRun) { | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
console.log('No matching workflow run found for this commit'); | ||
return; | ||
} | ||
return artifact.name == "push" | ||
})[0]; | ||
var artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
var download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: matchRun.id, | ||
artifact_id: matchArtifact.id, | ||
}); | ||
archive_format: 'zip', | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
var fs = require('fs'); | ||
return artifact.name == "push" | ||
})[0]; | ||
if (!matchArtifact) { | ||
fs.writeFileSync('${{github.workspace}}/push.zip', Buffer.from(download.data)); | ||
- run: unzip push.zip | ||
- name: prepare the artifact | ||
run: | | ||
mkdir -p obp-api/target/ | ||
cp push/obp-api-1.*.war obp-api/target/obp-api-1.10.1.war | ||
- name: Build the Docker image | ||
run: | | ||
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io | ||
docker build . --file .github/Dockerfile_PreBuild --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop | ||
docker push docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }} --all-tags | ||
echo docker done | ||
- uses: sigstore/cosign-installer@main | ||
|
||
- name: Write signing key to disk (only needed for `cosign sign --key`) | ||
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key | ||
|
||
- name: Sign container image | ||
run: | | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop-OC | ||
cosign sign -y --key cosign.key \ | ||
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest-OC | ||
env: | ||
COSIGN_PASSWORD: "${{secrets.COSIGN_PASSWORD}}" | ||
|
||
|
||
|
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
Oops, something went wrong.