Search code examples
javaspring-bootazure-web-app-servicegithub-actionscicd

No valid download found for version java21.x and package jdk: GitHub Actions and Azure App Service CI/CD


I am trying to deploy a Spring Boot Application (Java 21 and Spring Boot 3.2.3) on Azure App Service using GitHub Actions CI/CD. When building the project, I get an error during the build phase-

Error: No valid download found for version java21.x and package jdk. Check https://static.azul.com/zulu/bin/ for a list of valid versions or download your own jdk file and add the jdkFile argument

enter image description here

The workflow file:

name: Build and deploy JAR app to Azure Web App - examsoft-backend

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up Java version
        uses: actions/setup-java@v1
        with:
          java-version: 'java21'

      - name: Build with Maven
        run: mvn clean install

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v3
        with:
          name: java-app
          path: '${{ github.workspace }}/target/*.jar'

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    permissions:
      id-token: write #This is required for requesting the JWT
  
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v3
        with:
          name: java-app
      
      - name: Login to Azure
        uses: azure/login@v1
        with:
          client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_FF92B0C301434646B1D0CD303330856F }}
          tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_D618604DD90F451DA8AB1E4E258BE47D }}
          subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_0F7B6AA94D204A36AE6B659E8F4D603E }}

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'examsoft-backend'
          slot-name: 'Production'
          package: '*.jar'

And the build log:

Run actions/setup-java@v1
  with:
    java-version: java21
    java-package: jdk
    architecture: x64
    server-id: github
    server-username: GITHUB_ACTOR
    server-password: GITHUB_TOKEN
Error: No valid download found for version java21.x and package jdk. Check https://static.azul.com/zulu/bin/ for a list of valid versions or download your own jdk file and add the jdkFile argument

Can somebody please help me resolve the issue?


Solution

  • Supported version syntax

    The java-version input supports an exact version or a version range using SemVer notation:

    • major versions: 8, 11, 16, 17, 21
    • more specific versions: 17.0, 11.0,11.0.4, 8.0.232, 8.0.282+8
    • early access (EA) versions: 15-ea, 15.0.0-ea, 15.0.0-ea.2, 15.0.0+2-ea

    Setting up Java needs be like this:

          - name: Set up Java version
            uses: actions/setup-java@v1
            with:
              java-version: '21'