Skip to content

Update build.yml

Update build.yml #31

Workflow file for this run

name: Gradle Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Save Timestamp
if: github.event_name == 'push'
run: |
echo "timestamp=$(date +%s)" >> $GITHUB_ENV
- name: Get Commit Timestamp
if: github.event_name == 'push'
uses: actions/github-script@v7.0.1
with:
script: |
const commit = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.event.payload.commits[0][sha]
})
core.exportVariable('commitDate', commit.data.commit.committer.date)
- name: calculate tts
if: github.event_name == 'push'
run: |
commit_ts=$(date --date="${{env.commitDate}}" "+%s")
diff=$((${{env.timestamp}} - $commit_ts))
echo "Seconds since commit: ${diff}" >> $GITHUB_STEP_SUMMARY
- name: Checkout Code
uses: actions/checkout@v3
- name: Read Plugin Version
uses: madhead/read-java-properties@latest
id: version
with:
file: gradle.properties
property: version
default: latest
- name: Set Artifact Name
id: artifactName
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "artifact_name=${{ github.ref_name }}" >>$GITHUB_OUTPUT
else
echo "artifact_name=PR-${{ github.event.pull_request.number }}" >>$GITHUB_OUTPUT
fi
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
- name: Run Gradle Build
id: build
run: ./gradlew clean build -x containerTest
- name: Add Artifacts To Local Repository
id: artifactCopy
run: ./gradlew publishMavenPublicationToArtifactsRepository
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifactName.outputs.artifact_name }}
path: |
build/artifacts/de/tracetronic/jenkins/plugins/ecu-test-execution/${{ steps.version.outputs.value }}
if-no-files-found: error