Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

GitHub Action: Close PR errors with deployment_token was not provided. #1489

Open Official-James opened 3 weeks ago

Official-James commented 3 weeks ago

Describe the bug

Using the azure/static-web-apps-deploy GitHub Action, on closed PR action the following error appears:

deployment_token was not provided.
The deployment_token is required for deploying content. If you'd like to continue the run without deployment, add the configuration skip_deploy_on_missing_secrets set to true in your workflow file
An unknown exception has occurred

This is preventing cleanup of the preview environments in the Static Web App.

To Reproduce Steps to reproduce the behavior:

  1. Add the following as a job in GitHub Actions:

    close_pull_request_job:
    name: Close Pull Request Job
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
            app_location: '.'
            azure_static_web_apps_api_token: ${{ secrets.staticWebAppToken }}
            action: "close"
  2. Close PR to trigger
  3. The above error appears

Expected behavior PR to trigger on close and clean-up the preview environment

PipeItToDevNull commented 4 days ago

https://github.com/Azure/static-web-apps/issues/1342

This is the same issue, but I don't understand the fix

PipeItToDevNull commented 4 days ago

I obtained a token by going to the SWA and choosing "Manage deployment token" on the "Overview" page.

This token is then created as a Dependabot specific secret WITH THE SAME NAME as the normal token per https://github.com/Azure/static-web-apps/issues/788