|
| 1 | +name: Build spring-sleuth jar |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["develop"] |
| 6 | + paths: |
| 7 | + - "assets/spring-sleuth/src/**" |
| 8 | + - "assets/spring-sleuth/pom.xml" |
| 9 | + - ".github/workflows/build-spring-sleuth-jar.yml" |
| 10 | + pull_request: |
| 11 | + branches: ["develop"] |
| 12 | + paths: |
| 13 | + - "assets/spring-sleuth/src/**" |
| 14 | + - "assets/spring-sleuth/pom.xml" |
| 15 | + - ".github/workflows/build-spring-sleuth-jar.yml" |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + if: github.actor != 'github-actions[bot]' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: write |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v6 |
| 26 | + with: |
| 27 | + token: ${{ secrets.GIT_BOT_TOKEN || github.token }} |
| 28 | + |
| 29 | + - name: Set up Java |
| 30 | + uses: actions/setup-java@v4 |
| 31 | + with: |
| 32 | + distribution: temurin |
| 33 | + java-version: "17" |
| 34 | + cache: maven |
| 35 | + |
| 36 | + - name: Build jar with Maven |
| 37 | + working-directory: assets/spring-sleuth |
| 38 | + run: mvn package |
| 39 | + |
| 40 | + - name: Commit rebuilt jar to PR branch |
| 41 | + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && env.GIT_BOT_TOKEN != '' && env.GIT_BOT_NAME != '' && env.GIT_BOT_EMAIL != '' |
| 42 | + env: |
| 43 | + GIT_BOT_TOKEN: ${{ secrets.GIT_BOT_TOKEN }} |
| 44 | + GIT_BOT_NAME: ${{ secrets.GIT_BOT_NAME }} |
| 45 | + GIT_BOT_EMAIL: ${{ secrets.GIT_BOT_EMAIL }} |
| 46 | + run: | |
| 47 | + git config user.name "${GIT_BOT_NAME}" |
| 48 | + git config user.email "${GIT_BOT_EMAIL}" |
| 49 | + git remote set-url origin "https://x-access-token:${GIT_BOT_TOKEN}@github.com/${{ github.repository }}.git" |
| 50 | +
|
| 51 | + git add assets/spring-sleuth/target/spring-sleuth-0.0.1.jar |
| 52 | + if git diff --cached --quiet; then |
| 53 | + echo "No jar changes to commit" |
| 54 | + exit 0 |
| 55 | + fi |
| 56 | +
|
| 57 | + git commit -m "Build spring-sleuth-0.0.1.jar with 'mvn package'" |
| 58 | + git push origin "HEAD:${{ github.head_ref }}" |
| 59 | +
|
0 commit comments