Questions icon indicating copy to clipboard operation
Questions copied to clipboard

Maven release workflow doesn't trigger on new tag worklow

Open mohamed-ennahdi opened this issue 1 year ago • 0 comments

I have 2 workflows:

  • a maven release workflow, triggered by workflow_dispatch
  • a docker image creation supposed to be triggered by the aforementioned workflow (when a new tag is pushed)

I shouldn't use GITHUB_TOKEN when expecting a workflow to call another workflow, that's why I made my own Personal Access Token (PAS) and passed it in the first workflow (secrets.PAS_TOKEN).

Am I correctly using the PAS token with the Maven command ?

The release goal executed by maven pushes new tags indeed.

As a matter of fact, workflow_run is pointless as it does not work with tags.

The maven release workflow YAML:

name: Java CI with Maven to release latest SNAPSHOT version

on:
  workflow_dispatch:

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
    - name: Set up JDK 17
      uses: actions/setup-java@v4
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    - name: Configure Git user
      run: |
        git config user.email "[email protected]"
        git config user.name "Mohamed Ennahdi El Idrissi"
    - name: Build with Maven
      run: mvn -B release:clean release:prepare release:perform --file pom.xml
      env:
        GITHUB_TOKEN: ${{ secrets.PAS_TOKEN }}

The docker image creation workflow YAML:

name: Java CI with Maven to create and publish Docker image

on:
  push:
    tags:
    - '*'
    
jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
    - name: Set up JDK 17
      uses: actions/setup-java@v4
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    - name: Create docker image and push to docker hub (latest version)
      run: |
        echo $RELEASE_VERSION
        echo ${{ env.RELEASE_VERSION }}
        mvn -B spring-boot:build-image --file pom.xml

mohamed-ennahdi avatar Nov 28 '24 09:11 mohamed-ennahdi