|
| 1 | +# Synchronizes .netconfig-configured files with dotnet-file |
| 2 | +name: dotnet-file-core |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +env: |
| 7 | + DOTNET_NOLOGO: true |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: pwsh |
| 12 | + |
| 13 | +jobs: |
| 14 | + sync: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + continue-on-error: true |
| 17 | + steps: |
| 18 | + - name: 🤖 defaults |
| 19 | + uses: devlooped/actions-bot@v1 |
| 20 | + with: |
| 21 | + name: ${{ secrets.BOT_NAME }} |
| 22 | + email: ${{ secrets.BOT_EMAIL }} |
| 23 | + gh_token: ${{ secrets.GH_TOKEN }} |
| 24 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + |
| 26 | + - name: 🤘 checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + ref: main |
| 31 | + token: ${{ env.GH_TOKEN }} |
| 32 | + |
| 33 | + - name: ⌛ rate |
| 34 | + if: github.event_name != 'workflow_dispatch' |
| 35 | + run: | |
| 36 | + # add random sleep since we run on fixed schedule |
| 37 | + sleep (get-random -max 60) |
| 38 | + # get currently authenticated user rate limit info |
| 39 | + $rate = gh api rate_limit | convertfrom-json | select -expandproperty rate |
| 40 | + # if we don't have at least 100 requests left, wait until reset |
| 41 | + if ($rate.remaining -lt 10) { |
| 42 | + $wait = ($rate.reset - (Get-Date (Get-Date).ToUniversalTime() -UFormat %s)) |
| 43 | + echo "Rate limit remaining is $($rate.remaining), waiting for $($wait / 1000) seconds to reset" |
| 44 | + sleep $wait |
| 45 | + $rate = gh api rate_limit | convertfrom-json | select -expandproperty rate |
| 46 | + echo "Rate limit has reset to $($rate.remaining) requests" |
| 47 | + } |
| 48 | +
|
| 49 | + - name: 🔄 sync |
| 50 | + run: | |
| 51 | + dotnet tool update -g dotnet-gcm |
| 52 | + # store credentials in plaintext for linux compat |
| 53 | + git config --local credential.credentialStore plaintext |
| 54 | + dotnet gcm store --protocol=https --host=github.com --username=$env:GITHUB_ACTOR --password=$env:GH_TOKEN |
| 55 | + gh auth status |
| 56 | +
|
| 57 | + dotnet tool update -g dotnet-file |
| 58 | + $changelog = "$([System.IO.Path]::GetTempPath())dotnet-file.md" |
| 59 | + dotnet file sync -c:$changelog |
| 60 | + if (test-path $changelog) { |
| 61 | + echo 'CHANGES<<EOF' >> $env:GITHUB_ENV |
| 62 | + cat $changelog >> $env:GITHUB_ENV |
| 63 | + echo 'EOF' >> $env:GITHUB_ENV |
| 64 | + cat $changelog |
| 65 | + } else { |
| 66 | + echo 'No changelog was generated' |
| 67 | + } |
| 68 | +
|
| 69 | + - name: +Mᐁ includes |
| 70 | + uses: devlooped/actions-includes@v1 |
| 71 | + with: |
| 72 | + validate: false |
| 73 | + |
| 74 | + - name: ✍ pull request |
| 75 | + uses: peter-evans/create-pull-request@v7 |
| 76 | + with: |
| 77 | + base: main |
| 78 | + branch: dotnet-file-sync |
| 79 | + delete-branch: true |
| 80 | + labels: dependencies |
| 81 | + author: ${{ env.BOT_AUTHOR }} |
| 82 | + committer: ${{ env.BOT_AUTHOR }} |
| 83 | + commit-message: ⬆️ Bump files with dotnet-file sync |
| 84 | + |
| 85 | + ${{ env.CHANGES }} |
| 86 | + title: "⬆️ Bump files with dotnet-file sync" |
| 87 | + body: ${{ env.CHANGES }} |
| 88 | + token: ${{ env.GH_TOKEN }} |
0 commit comments