New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deploying from Azure DevOps Pipeline Releases #368
Comments
I tried publishing my source code to a artifact location as shown below... # JOB: Gather Static Web App Source Code
- job: GatherStaticWebApp
displayName: 'Gather Static Web App Source Code'
steps:
# TASK: Publish Static Web App Artifacts
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: staticwebapp_drop'
inputs:
PathtoPublish: 'src' # Folder location of source code in git repo
ArtifactName: 'staticwebapp_drop' I then tried to set the inputs the downloaded source code location, but no luck so far. Any help would be greatly appricated. # DEPLOYMENT: Deploy Static Web App
- deployment: DeployStaticWebApp
displayName: 'Deploy Static Web App'
pool:
vmImage: ubuntu-latest
environment: DEV
strategy:
runOnce:
deploy:
steps:
# TASK: Deploy My App
- task: AzureStaticWebApp@0
displayName: 'Deploy My App'
inputs:
app_location: '$(Pipeline.Workspace)/staticwebapp_drop/MyApp.Web'
output_location: 'wwwroot'
api_location: '$(Pipeline.Workspace)/staticwebapp_drop/MyApp.Api'
routes_location: '$(Pipeline.Workspace)/staticwebapp_drop/MyApp.Web/wwwroot'
env:
azure_static_web_apps_api_token: $(deployment_token_dev) Below is the error I keep getting...
Craig |
Based on the error in my previous post, it will only scan your repo for the files to build and pull into the Static Web App. I could just use another job to deploy the web app, instead of a deployment, but this defeats my purpose of putting approval gates in for each of my environments. If I find a way to get this to work, I will try to reply back to this thread. |
@craigholdheide i'm trying to do exactly the same. have you maybe found a solution for this? |
@lukju I ended up creating a PROD stage with a job to run the static web app deploy task. I also created an approve stage that does nothing more than echo the text "Approved to PROD". Since this is a deployment, I can add an environment to it, called ApproveToProd, and then created a preapproval. Below are the last two stages of my yml deployment script if that helps. Also, I found this documentation below to be helpful... # DEV Stage before the approve stage not shown
# DEV stage similar to PROD stage
# STAGE: APPROVE
- stage: APPROVE
jobs:
# DEPLOYMENT: ApproveToProd
- deployment: ApproveToProd
displayName: Approve To PROD
pool:
vmImage: ubuntu-latest
environment: ApproveToProd
strategy:
runOnce:
deploy:
steps:
- script: echo Approved to PROD
# STAGE: PROD
- stage: PROD
jobs:
# JOB: Deploy Static Web App
- job: DeployStaticWebApp
displayName: 'Deploy Static Web App'
pool:
vmImage: ubuntu-latest
steps:
# TASK: Deploy Blazor App
- task: AzureStaticWebApp@0
displayName: 'Deploy Blazor App'
inputs:
app_location: 'src/MyApp.Web'
output_location: 'wwwroot'
api_location: 'src/MyApp.Api'
routes_location: 'src/MyApp.Web/wwwroot'
env:
azure_static_web_apps_api_token: $(deployment_token_prod) Unfortunately this is not the solution I hoped for, but the Azure Static Web App deploy task seems to only want to pull from source control and not from and artifact location. Hopefully this helps. |
It looks like AzureStaticWebApp is set up as a combined build and deploy in a single task? I would prefer if these were separate tasks (or more likely, just a AzureStaticWebApp Deploy task, with the expectation that any static app framework will have its own independent Build tasks), with similar goal as others in this thread: have a Build stage that creates an artifact, followed by Deploy stages using that artifact. It looks like there's been some updates to this task in a 0.0.1-preview branch that has not been published for use, including a It seems to use a Docker image |
I had the same issue, took me a while but I worked out a different workaround that lets you keep using a deployment job, with the difference that you do check out the full repository (which is not the default behaviour for deployment jobs). I figured: it works if I build from my source code, so what if I download the prebuilt artifact into the directory in which the build output is normally written? If pointing the Build stage - I skipped the build steps as these are highly dependent from your project, the artifacts publishing is the relevant part: stages:
- stage: Build
jobs:
- job: Build
displayName: "Build & publish"
steps:
### Build steps - redacted away ###
- publish: ./src/website/build # Notice the directory being published
artifact: website
displayName: "Publish website artifacts" Deploy stage (which is in a different template which has stages:
- stage: "${{ parameters.environment }}"
displayName: "Deploy to ${{ parameters.environment }}"
jobs:
- deployment: DeployTo${{ parameters.environment }}
displayName: "Deploy to ${{ parameters.environment }}"
environment: "kmodo-${{ parameters.environment }}"
strategy:
runOnce:
deploy:
steps:
# Check out the source code manually as this is not done automatically and
# it seems AzureStaticWebApp@0 needs this in order to function properly
- checkout: self
submodules: true
# Download artifacts manually so we can tweak the target directory.
# Needed so we can point AzureStaticWebApp@0 to the pre-built assets.
- task: DownloadPipelineArtifact@2
inputs:
artifact: website
path: ./src/website/build # Put the assets back where they came from!
displayName: "Download website artifacts"
- task: AzureStaticWebApp@0
inputs:
# Point to the pre-built assets so Oryx build fails and it assumes it was already built
app_location: "src/website/build"
env:
azure_static_web_apps_api_token: $(kmodo-${{ parameters.environment }}-swa-deployment-token) And the relevant pieces of the pipeline output:
and finally the deploy:
As you can see in the above logs, Oryx is unable to determine the language (and thus the build steps) and assumes the assets are already built. It then continues the deployment, which succeeds. Hope this helps! |
|
Similar to this which works great for deploying from DevOps pipelines, can we get support for deploying directly from pipeline releases in ADO? Thanks.
The text was updated successfully, but these errors were encountered: