Skip to content

Instantly share code, notes, and snippets.

@adamkobor
Last active November 10, 2022 18:48
Show Gist options
  • Save adamkobor/0ea98326b9589c211e3ee5dd760056a2 to your computer and use it in GitHub Desktop.
Save adamkobor/0ea98326b9589c211e3ee5dd760056a2 to your computer and use it in GitHub Desktop.
A simple GitHub workflow that is able to detect the changes of the configured files/directories and execute other steps (e.g. adding comments) based on the output
name: Changelog check
on:
pull_request:
branches: [ main ]
env:
MESSAGE_ID: "${{ github.ref_name }}-changelog-comment"
jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
CHANGES.md
- name: Upsert comment if CHANGES.md has not been changed
if: steps.changed-files.outputs.any_modified != 'true'
uses: mshick/add-pr-comment@v2
with:
message: |
**⚠️ CHANGES.md has not been changed**
That might be totally fine, but please make it sure that you didn't forget to update it!
message-id: ${{ env.MESSAGE_ID }}
- name: Upsert comment if CHANGES.md has been changed
if: steps.changed-files.outputs.any_modified == 'true'
uses: mshick/add-pr-comment@v2
with:
message: |
**✅ CHANGES.md has been changed**
It doesn't mean that it contains a useful entry, but at least it was modified.
message-id: ${{ env.MESSAGE_ID }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment