Home  >  All Categories  >  Dev  >  How to check if there are uncommited changes in Github Actions?

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

该博客没有评论系统,我正在实验有意义的讨论是否更易在社群中发生,不知道为什么,人在社群中,似乎会有更好的行为规范。然后如果有高质量的讨论,我会手动再精选到原文。为此,我建立了一个 Telegram 讨论群组,你可以在里面讨论这篇文章,点此复制文章标题和链接