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

Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen