Skip to content
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

deployment_environment: doesn't work #1551

Open
sonomirco opened this issue Sep 27, 2024 · 4 comments
Open

deployment_environment: doesn't work #1551

sonomirco opened this issue Sep 27, 2024 · 4 comments

Comments

@sonomirco
Copy link

sonomirco commented Sep 27, 2024

Describe the bug

I followed these link.
https://learn.microsoft.com/en-us/azure/static-web-apps/named-environments?tabs=github-actions

#787

This is the action

name: Deploy documentation for development

on:
  workflow_dispatch:
  pull_request:
    types: [opened, synchronize, closed]
    branches:
      - develop
      - "dev/**"
      - "feat/**"
    paths:
      - "web/**"
      - "media/**"

jobs:
  deploy_dev_doc:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    environment:
      name: development
      url: https://mango-desert-0545fe40f-development.eastus2.5.azurestaticapps.net
    steps:
      - name: 🛎 Checkout
        uses: actions/checkout@v4
        with:
          submodules: true
          
      - name: 🚀 Build and deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }}
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          action: "upload"
          app_location: "./web"
          api_location: ""
          output_location: "build"
          deployment_environment: "development"

Expected behavior
I should have this URL https://mango-desert-0545fe40f-development.eastus2.5.azurestaticapps.net generated in the Azure Static Web App, but I have this one https://mango-desert-0545fe40f-78.eastus2.5.azurestaticapps.net/.auth/login/aad/callback which it takes the PR's ID.

@higharc91
Copy link

I am experiencing the same issue with my project.

@sindrebakk1
Copy link

I am experiencing the same result. This is blocking us from setting up a CORS policy for preview environments

@sindrebakk1
Copy link

I managed to "solve" this issue. When a deployment is triggered by a pull request, the deployment environment will be your pr number. This behaviour seems to override the 'deployment_environment' option in the workflow. To deploy to a named environment the workflow trigger must be 'push'. (might work for other triggers as well, I have only tried push)

@sonomirco
Copy link
Author

@sindrebakk1 thanks for this information.
Some extra checks need to be added if I want to capture only changes pushed to a branch after a PR is opened, considering that using push will catch everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants