|
| 1 | +name: Rust CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + #branches: [main] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + prepare: |
| 11 | + name: Determine image tag |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: | |
| 14 | + github.ref_name == 'main' || |
| 15 | + startsWith(github.head_ref, 'feature/') || |
| 16 | + startsWith(github.head_ref, 'bugfix/') || |
| 17 | + (github.event_name == 'workflow_dispatch' && (startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/'))) |
| 18 | + outputs: |
| 19 | + image_tag: ${{ steps.determine-tag.outputs.image_tag }} |
| 20 | + jar_path: ${{ steps.determine-tag.outputs.jar_path }} |
| 21 | + steps: |
| 22 | + - name: Determine base tag |
| 23 | + id: determine-tag |
| 24 | + run: | |
| 25 | + if [ "${{ github.event_name }}" = "pull_request" ] ; then |
| 26 | + SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8) |
| 27 | + else |
| 28 | + SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8) |
| 29 | + fi |
| 30 | +
|
| 31 | + if [ "${{ github.ref_name }}" = "main" ] ; then |
| 32 | + echo "Processing main branch" |
| 33 | + echo "image_tag=dev-${SHORT_SHA}" | tee -a $GITHUB_OUTPUT |
| 34 | + else |
| 35 | + # This covers feature/ and bugfix/ branches |
| 36 | + echo "Processing feature/bugfix branch ${{ github.head_ref }}" |
| 37 | + echo "image_tag=feature-${SHORT_SHA}" | tee -a $GITHUB_OUTPUT |
| 38 | + fi |
| 39 | + echo "jar_path=$(./gradlew properties | grep jarPathForOCI | cut -d" " -f2)" | tee -a $GITHUB_OUTPUT |
| 40 | +
|
| 41 | + build-oci-image: |
| 42 | + name: Build OCI images |
| 43 | + needs: prepare |
| 44 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/docker-build.yml@feature/improve-docker-build |
| 45 | + with: |
| 46 | + image-name: docker-regis.iex.ec/iexec-blockchain-adpter-api |
| 47 | + image-tag: ${{ needs.prepare.outputs.image_tag }} |
| 48 | + dockerfile: Dockerfile |
| 49 | + context: . |
| 50 | + registry: docker-regis.iex.ec |
| 51 | + push: true |
| 52 | + security-scan: true |
| 53 | + security-report: "sarif" |
| 54 | + hadolint: true |
| 55 | + platforms: linux/amd64 |
| 56 | + build-args: | |
| 57 | + jar=${{ needs.prepare.outputs.jar_path }} |
| 58 | + secrets: |
| 59 | + username: ${{ secrets.NEXUS_USERNAME }} |
| 60 | + password: ${{ secrets.NEXUS_PASSWORD }} |
0 commit comments