|  | 
|  | 1 | +name: Azure Static Web App Root | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  workflow_dispatch: | 
|  | 5 | +  push: | 
|  | 6 | +    branches: | 
|  | 7 | +      - v1.15 | 
|  | 8 | +  pull_request: | 
|  | 9 | +    types: [opened, synchronize, reopened, closed] | 
|  | 10 | +    branches: | 
|  | 11 | +      - v1.15 | 
|  | 12 | + | 
|  | 13 | +concurrency: | 
|  | 14 | +  # Cancel the previously triggered build for only PR build. | 
|  | 15 | +  group: website-${{ github.event.pull_request.number || github.sha }} | 
|  | 16 | +  cancel-in-progress: true | 
|  | 17 | + | 
|  | 18 | +jobs: | 
|  | 19 | +  build_and_deploy_job: | 
|  | 20 | +    name: Build Hugo Website | 
|  | 21 | +    if: github.event.action != 'closed' | 
|  | 22 | +    runs-on: ubuntu-latest | 
|  | 23 | +    env: | 
|  | 24 | +      SWA_BASE: 'proud-bay-0e9e0e81e' | 
|  | 25 | +      HUGO_ENV: production | 
|  | 26 | +    steps: | 
|  | 27 | +      - name: Checkout docs repo | 
|  | 28 | +        uses: actions/checkout@v4 | 
|  | 29 | +        with: | 
|  | 30 | +          submodules: true | 
|  | 31 | +      - name: Setup Node | 
|  | 32 | +        uses: actions/setup-node@v4 | 
|  | 33 | +        with: | 
|  | 34 | +          node-version: '18' | 
|  | 35 | +      - name: Setup Hugo | 
|  | 36 | + | 
|  | 37 | +        with: | 
|  | 38 | +          hugo-version: 0.147.9 | 
|  | 39 | +          extended: true | 
|  | 40 | +      - name: Setup Submodules | 
|  | 41 | +        run: | | 
|  | 42 | +          cd daprdocs | 
|  | 43 | +          git submodule update --init --recursive | 
|  | 44 | +          cd .. | 
|  | 45 | +          sudo npm install -D --save autoprefixer | 
|  | 46 | +          sudo npm install -D --save postcss-cli | 
|  | 47 | +      - name: Build Hugo Website | 
|  | 48 | +        run: | | 
|  | 49 | +          git config --global --add safe.directory /github/workspace | 
|  | 50 | +          if [ $GITHUB_EVENT_NAME == 'pull_request' ]; then | 
|  | 51 | +            STAGING_URL="https://${SWA_BASE}-${{github.event.number}}.westus2.azurestaticapps.net/" | 
|  | 52 | +          fi | 
|  | 53 | +          hugo ${STAGING_URL+-b "$STAGING_URL"} | 
|  | 54 | +      - name: Deploy docs site | 
|  | 55 | +        uses: Azure/static-web-apps-deploy@v1 | 
|  | 56 | +        with: | 
|  | 57 | +          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_BAY_0E9E0E81E }} | 
|  | 58 | +          repo_token: ${{ secrets.GITHUB_TOKEN }} | 
|  | 59 | +          action: "upload" | 
|  | 60 | +          app_location: "/daprdocs/public/" | 
|  | 61 | +          output_location: "/" | 
|  | 62 | +          skip_app_build: true | 
|  | 63 | +          skip_deploy_on_missing_secrets: true | 
|  | 64 | +      - name: Upload Hugo artifacts | 
|  | 65 | +        uses: actions/upload-artifact@v4 | 
|  | 66 | +        with: | 
|  | 67 | +          name: hugo_build | 
|  | 68 | +          path: ./daprdocs/public/ | 
|  | 69 | +          if-no-files-found: error | 
|  | 70 | + | 
|  | 71 | +  close_staging_site: | 
|  | 72 | +    if: github.event_name == 'pull_request' && github.event.action == 'closed' | 
|  | 73 | +    runs-on: ubuntu-latest | 
|  | 74 | +    name: Close Pull Request Job | 
|  | 75 | +    steps: | 
|  | 76 | +      - name: Close Pull Request | 
|  | 77 | +        id: closepullrequest | 
|  | 78 | +        uses: Azure/static-web-apps-deploy@v1 | 
|  | 79 | +        with: | 
|  | 80 | +          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_BAY_0E9E0E81E }} | 
|  | 81 | +          action: "close" | 
|  | 82 | +          skip_deploy_on_missing_secrets: true | 
|  | 83 | + | 
|  | 84 | +  algolia_index: | 
|  | 85 | +    name: Index site for Algolia | 
|  | 86 | +    if: github.event_name == 'push' | 
|  | 87 | +    needs: ['build_and_deploy_job'] | 
|  | 88 | +    runs-on: ubuntu-latest | 
|  | 89 | +    env: | 
|  | 90 | +      ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} | 
|  | 91 | +      ALGOLIA_API_WRITE_KEY: ${{ secrets.ALGOLIA_API_WRITE_KEY }} | 
|  | 92 | +      ALGOLIA_INDEX_NAME: daprdocs | 
|  | 93 | +    steps: | 
|  | 94 | +      - name: Checkout docs repo | 
|  | 95 | +        uses: actions/checkout@v4 | 
|  | 96 | +        with: | 
|  | 97 | +          submodules: false | 
|  | 98 | +      - name: Download Hugo artifacts | 
|  | 99 | +        uses: actions/download-artifact@v3 | 
|  | 100 | +        with: | 
|  | 101 | +          name: hugo_build | 
|  | 102 | +          path: site/ | 
|  | 103 | +      - name: Install Python packages | 
|  | 104 | +        run: | | 
|  | 105 | +          pip install --upgrade bs4 | 
|  | 106 | +          pip install --upgrade 'algoliasearch>=2.0,<3.0' | 
|  | 107 | +      - name: Index site | 
|  | 108 | +        run: python ./.github/scripts/algolia.py ./site | 
0 commit comments