I’ve been stuck for a while now on the issue I’m having where when I want to deploy my java app to Azure. It doesn’t recognise the artifact that I build in a previous workflow run. these are the build and deploy files:
name: Build JAR app - kobeodbCR-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: "17"
- name: Build with Maven
run: mvn clean install
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: java-app
path: "${{ github.workspace }}/target/*.jar"
name: Deploy JAR app to Azure Web App - kobeodbCR-backend
on:
workflow_run:
workflows: ["Build JAR app - kobeodbCR-backend"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: java-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: "kobeodbCR-backend"
slot-name: "Production"
package: "*.jar"
publish-profile: ${{ ... }}
and this is the error im getting:
deploy
Unable to download artifact(s): Artifact not found for name: java-app Please ensure that your artifact is not expired and the artifact was uploaded using a compatible version of toolkit/upload-artifact. For more information, visit the GitHub Artifacts FAQ: https://github.com/actions/toolkit/blob/main/packages/artifact/docs/faq.md
Why is this happening?
The build workflow completes successfully, and the artifact is created, but the deploy workflow fails after give or take 10 seconds.
I’ve tried a few different things, mostly recommendations from chatGPT, but none of them have successfully worked.
2
Answers
There is no scope/context in the workflowB. You will need to to generate a token based on a github app that you need to add to your repo. Something like this:
To create the github app here is the doc: https://docs.github.com/es/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps
An alternative much simplier would be to fuse both worklows and set an input parameter so you can decide when you upload or not the artefact. Example:
you need to specify run id in the download-artifact step to accomplish this as these workflows running independently