How to check if there are uncommited changes in Github Actions?

Check if there are uncommited changes in Github Actions workflow file.

name: Github Actions check if there are uncommited changes
on:
  repository_dispatch:
  workflow_dispatch:
  push:
    branches:
      - main
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2
      - run: touch index.html
      - name: chown
        run: sudo chown -R $USER:$USER ./
      - name: git config
        run: git config --global user.name "github-actions[bot]" && git config --global user.email github-actions-bot@users.noreply.github.com
      - name: git add
        run: git add .
      - run: git status
      - id: isChanged
        run: git diff-index --cached --quiet HEAD || echo '::set-output name=changed::true'
      - run: echo ${{ steps.isChanged.outputs.changed }}
      - if: ${{ steps.isChanged.outputs.changed == 'true' }}
        run: echo 'yes, changed'
      - if: ${{ steps.isChanged.outputs.changed != 'true' }}
        run: echo 'no any change'
Category: Dev 
TagsGit
Published:  Β· Updated:   πŸ“ Edit this page

ResponseπŸ”—

Have you written a response to this? Let me know the article or tweet URL (Article or tweet content needs to include the URL of this article, learn more about webmention here).

The response will be automatically collected by webmention.io bot, and another bot will automatically post it here within 24 hours, I wrote an article about how to achieve this. You can also send your response via mail owen@owenyoung.com or Twitter DM