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
330 stars 57 forks source link

Close pull request job does not give the corresponding deployed url - Github actions #682

Open arunmmanoharan opened 2 years ago

arunmmanoharan commented 2 years ago

Describe the bug

I would like to get the staging url created in the previous (build_and_deploy_job) job in the close_pull_request_job job. My goal is to go ahead and remove the url from the redirectUri list in Azure app service. But for some reason, when I tried steps.closepullrequest.outputs.static_web_app_url, it is an empty string.

To Reproduce Steps to reproduce the behavior: name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - dev
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - dev

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

      - uses: actions/cache@v2
        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-

      - 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_API_TOKEN_HAPPY_RIVER_01F5A930F }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "/" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "build" # Built app content directory - optional
        env:
          VITE_AG_GRID_LICENSE_KEY: ${{secrets.VITE_AG_GRID_LICENSE_KEY}}
          VITE_API_SCOPE: ${{secrets.VITE_API_SCOPE}}
          VITE_CLIENT_ID: ${{secrets.VITE_CLIENT_ID}}
          VITE_SOURCE_LOADER_BASE_URL: ${{secrets.VITE_SOURCE_LOADER_BASE_URL_DEV}}
          VITE_TENANT_ID: ${{secrets.VITE_TENANT_ID}}
      - run: echo ${{ steps.builddeploy.outputs.static_web_app_url }}

      - name: Add redirect uri
        id: addRedirectUri
        uses: fjogeleit/http-request-action@master
        with:
          url: 'url'
          method: 'POST'
          data: '{"redirectURI": "${{steps.builddeploy.outputs.static_web_app_url}}", "route": "create"}'

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_RIVER_01F5A930F }}
          action: "close"
      - run: echo ${{ steps.closepullrequest.outputs.static_web_app_url }}
      - name: Remove redirect uri
        id: removeRedirectUri
        uses: fjogeleit/http-request-action@master
        with:
          url: 'url'
          method: 'POST'
          data: '{"redirectURI": "${{ steps.closepullrequest.outputs.static_web_app_url }}", "route": "delete"}'

Expected behavior Should give me the url. I have access to the pull_request_number. An alternate solution for me is to get the subdomain so I can compose the url on my own.

Screenshots If applicable, add screenshots to help explain your problem.

Device info (if applicable):

Additional context Add any other context about the problem here.

SvenAelterman commented 2 years ago

@a2441918 I am sorry I don't have an answer for you. However, could you share how you create the URL to create or remove the redirect URL?