github.com/terraform-linters/tflint-ruleset-azurerm@v0.26.0/.github/workflows/watch.yml (about)

     1  name: watch
     2  
     3  on:
     4    schedule:
     5      - cron: "0 0 * * *"
     6  
     7  jobs:
     8    azure_docs:
     9      name: azure-docs
    10      runs-on: ubuntu-latest
    11      steps:
    12      - name: Checkout
    13        uses: actions/checkout@v4
    14      - name: Calculate diff
    15        run: |
    16          curl https://raw.githubusercontent.com/MicrosoftDocs/azure-docs/main/articles/virtual-machines/sizes.md --output .github/snapshots/size.md
    17          git diff > snapshot.diff
    18      - name: Create an issue
    19        uses: actions/github-script@v7
    20        with:
    21          github-token: ${{secrets.GITHUB_TOKEN}}
    22          script: |
    23            const issues = await github.rest.issues.listForRepo({
    24              owner: 'terraform-linters',
    25              repo: 'tflint-ruleset-azurerm',
    26              state: 'open',
    27              labels: ['bot']
    28            })
    29            if (issues.data.length !== 0) {
    30              console.log("Issue already opened. Skipped.")
    31              return
    32            }
    33  
    34            const fs = require('fs')
    35            const data = fs.readFileSync('snapshot.diff', 'utf-8')
    36            if (data === "") {
    37              console.log("No diff. Skipped.")
    38              return
    39            }
    40  
    41            github.rest.issues.create({
    42              owner: 'terraform-linters',
    43              repo: 'tflint-ruleset-azurerm',
    44              title: '🤖 MicrosoftDocs/azure-docs Changes Report',
    45              body: "Changes found from the saved snapshots :eyes:\n\n```diff\n" + data + "```\n\nhttps://github.com/MicrosoftDocs/azure-docs/blob/main/articles/virtual-machines/sizes.md",
    46              labels: ['bot'],
    47            })