Skip to content

Commit 9dd7f05

Browse files
committed
WIP
1 parent cd3b8ab commit 9dd7f05

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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: Build jar
49+
id: jar-path
50+
run: |
51+
gradle build
52+
echo "jar_path=$(gradle properties | grep jarPathForOCI | cut -d" " -f2)" | tee -a $GITHUB_OUTPUT
53+
env:
54+
ORG_GRADLE_PROJECT_nexusUser: ${{ secrets.NEXUS_USERNAME }}
55+
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}
56+
57+
build-oci-image:
58+
name: Build OCI images
59+
needs: prepare
60+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/docker-build.yml@feature/improve-docker-build
61+
with:
62+
image-name: docker-regis.iex.ec/iexec-blockchain-adpter-api
63+
image-tag: ${{ needs.prepare.outputs.image_tag }}
64+
dockerfile: Dockerfile
65+
context: .
66+
registry: docker-regis.iex.ec
67+
push: true
68+
security-scan: true
69+
security-report: "sarif"
70+
hadolint: true
71+
platforms: linux/amd64
72+
build-args: |
73+
jar=${{ needs.prepare.outputs.jar_path }}
74+
secrets:
75+
username: ${{ secrets.NEXUS_USERNAME }}
76+
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)