Update Service Fabric SDK #99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Service Fabric SDK | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' | |
| workflow_dispatch: | |
| jobs: | |
| update-sdk: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| # Use your PAT so future `git push` uses it | |
| token: ${{ secrets.GH_PAT }} | |
| persist-credentials: true | |
| - name: Update Service Fabric SDK URI | |
| env: | |
| # Give GitHub CLI the PAT (explicitly use GH_TOKEN) | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| set -euo pipefail | |
| page_content=$(curl -s https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-get-started) | |
| download_link=$(echo "$page_content" | grep -oP 'https:\/\/download\.microsoft\.com\/download\/[a-zA-Z0-9\/\.\-]*MicrosoftServiceFabric\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.exe' | head -1) | |
| if [ -z "$download_link" ]; then | |
| echo "No download link found :-(" | |
| exit 1 | |
| fi | |
| echo "Download link: $download_link" | |
| if [[ $download_link =~ ^https://download\.microsoft\.com/download/.*/MicrosoftServiceFabric\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.exe$ ]]; then | |
| sed -i -E "s|https://download.microsoft.com/download/.*/MicrosoftServiceFabric\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.exe|$download_link|g" .github/workflows/NuGetCD.yml | |
| sed -i -E "s|https://download.microsoft.com/download/.*/MicrosoftServiceFabric\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.exe|$download_link|g" .github/workflows/ci.yml | |
| if ! git diff --exit-code .github/workflows/NuGetCD.yml .github/workflows/ci.yml; then | |
| echo "Changes detected in workflow files" | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| branch_name="update-service-fabric-sdk-$(date +%Y%m%d%H%M%S)" | |
| git checkout -b "$branch_name" | |
| git add .github/workflows/NuGetCD.yml .github/workflows/ci.yml | |
| git commit -m "Update Service Fabric SDK download link to latest version" | |
| git push origin "$branch_name" | |
| # Use default branch dynamically (often 'main' not 'master') | |
| gh pr create \ | |
| --title "Update Service Fabric SDK download link" \ | |
| --body "This PR updates the Service Fabric SDK download link to the latest version: $download_link" \ | |
| --head "$branch_name" \ | |
| --base "${{ github.event.repository.default_branch }}" | |
| else | |
| echo "No changes detected in the workflow files." | |
| fi | |
| else | |
| echo "No valid download link found or link format is incorrect." | |
| exit 1 | |
| fi |