Skip to content

Commit 671207d

Browse files
committed
WIP
1 parent fdaba26 commit 671207d

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Rust CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
prepare:
10+
name: Determine image tag
11+
#runs-on: ubuntu-latest
12+
runs-on:
13+
group: Azure_runners
14+
container:
15+
image: gradle:8.10.2-jdk17-alpine
16+
#if: |
17+
# github.ref_name == 'main' ||
18+
# startsWith(github.head_ref, 'feature/') ||
19+
# startsWith(github.head_ref, 'bugfix/') ||
20+
# (github.event_name == 'workflow_dispatch' && (startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/')))
21+
outputs:
22+
image_tag: ${{ steps.determine-tag.outputs.image_tag }}
23+
jar_path: ${{ steps.jar-path.outputs.jar_path }}
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Determine base tag
31+
id: determine-tag
32+
run: |
33+
if [ "${{ github.event_name }}" = "pull_request" ] ; then
34+
SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8)
35+
else
36+
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
37+
fi
38+
39+
if [ "${{ github.ref_name }}" = "main" ] ; then
40+
echo "Processing main branch"
41+
echo "image_tag=dev-${SHORT_SHA}" | tee -a $GITHUB_OUTPUT
42+
else
43+
# This covers feature/ and bugfix/ branches
44+
echo "Processing feature/bugfix branch ${{ github.head_ref }}"
45+
echo "image_tag=feature-${SHORT_SHA}" | tee -a $GITHUB_OUTPUT
46+
fi
47+
48+
- name: Login to Docker Regis
49+
uses: docker/login-action@v3
50+
with:
51+
registry: docker-regis.iex.ec
52+
username: ${{ secrets.NEXUS_USERNAME }}
53+
password: ${{ secrets.NEXUS_PASSWORD }}
54+
55+
- name: Build jar
56+
id: jar-path
57+
run: |
58+
env | grep 'nexusUser'
59+
gradle build
60+
echo "jar_path=$(gradle properties | grep jarPathForOCI | cut -d" " -f2)" | tee -a $GITHUB_OUTPUT
61+
env:
62+
ORG_GRADLE_PROJECT_nexusUser: ${{ secrets.NEXUS_USERNAME }}
63+
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}
64+
65+
build-oci-image:
66+
name: Build OCI images
67+
needs: prepare
68+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/docker-build.yml@feature/improve-docker-build
69+
with:
70+
image-name: docker-regis.iex.ec/iexec-blockchain-adpter-api
71+
image-tag: ${{ needs.prepare.outputs.image_tag }}
72+
dockerfile: Dockerfile
73+
context: .
74+
registry: docker-regis.iex.ec
75+
push: false
76+
security-scan: true
77+
security-report: "sarif"
78+
hadolint: true
79+
platforms: linux/amd64
80+
build-args: |
81+
jar=${{ needs.prepare.outputs.jar_path }}
82+
secrets:
83+
username: ${{ secrets.NEXUS_USERNAME }}
84+
password: ${{ secrets.NEXUS_PASSWORD }}

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
buildJavaProject(
33
integrationTestsEnvVars: ['BROKER_PRIVATE_KEY'],
44
shouldPublishJars: true,
5-
shouldPublishDockerImages: true)
5+
shouldPublishDockerImages: false)

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ publishing {
141141

142142
ext.jarPathForOCI = relativePath(tasks.bootJar.outputs.files.singleFile)
143143
ext.gitShortCommit = 'git rev-parse --short=8 HEAD'.execute().text.trim()
144-
ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remote.origin.url) .git'].execute().text.trim()
145144

146145
tasks.register('buildImage', Exec) {
147146
group 'Build'
148147
description 'Builds an OCI image from a Dockerfile.'
149148
dependsOn bootJar
150-
commandLine 'docker', 'build', '--build-arg', 'jar=' + jarPathForOCI, '-t', ociImageName + ':dev', '.'
149+
commandLine 'docker', 'build', '--build-arg', 'jar=' + jarPathForOCI, '-t', 'local/' + rootProject.name + ':dev', '.'
151150
}

0 commit comments

Comments
 (0)