|
| 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 }} |
0 commit comments