Run the GHA command only when there is a change in specific folder

0

I want to update the AWS cloudformation stack only when there is a change in the deploy folder.

In my GHA I am trying to do this but its not working

jobs:
  aws_service_and_Infra_creation_updation:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Check for changes in deploy folder
        id: check_changes
        run: |
          changed_files=$(git diff HEAD main -- deploy || echo changed)
          if [ -n "$changed_files" ]; then
            echo "Changes detected in deploy folder."
            echo "changes=true" >> $GITHUB_ENV
          else
            echo "No changes in deploy folder."
            echo "changes=false" >> $GITHUB_ENV
          fi
      - name: update the stack
        if: steps.check_changes.outputs.changes == 'true'
        run: make update-stack

Please help what should i change or any other way of doing this through GHA

asked 5 months ago123 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions