Skip to content

Instantly share code, notes, and snippets.

@dnedrow
Last active February 6, 2025 20:28
Show Gist options
  • Select an option

  • Save dnedrow/574967630ddde1a90426bc102559d993 to your computer and use it in GitHub Desktop.

Select an option

Save dnedrow/574967630ddde1a90426bc102559d993 to your computer and use it in GitHub Desktop.
Skip GitHub Actions workflow step(s) if there are no code changes
-- https://stackoverflow.com/q/73109333
name: push
on: [push]
jobs:
list-contents:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: ls ./src/content/ > ./src/_content.txt
- run: if [[ "$(git diff --exit-code src/_content.txt)" =~ 'diff' ]]; then echo "IS_VALID=true" >> $GITHUB_ENV; else echo "IS_VALID=false" >> $GITHUB_ENV ;fi
- if: ${{ env.IS_VALID == 'true' }}
run: |
git config --local user.email "antboehler@gmail.com"
git config --local user.name "AntVil"
git add ./src/_content.txt
git commit -m "update _content.txt"
- if: ${{ env.IS_VALID == 'true' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment