Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I let the workflow to detect the changes only in the certain micro service? #766

Closed
MemphisMeng opened this issue Nov 6, 2022 · 3 comments · Fixed by #773
Closed

Comments

@MemphisMeng
Copy link

I am having a monorepo-like repo but it's not fully configured so it's a combination of several folders. Each subfolder has its own Dockerfile and my idea is to only let docker build the Dockerfile of the folder where there are new changes. Currently, I am working on a dev branch that already has an open pull request, the changes can be introduced by either git-push or pull request merge once the development is complete and the branch is merged.

It seems like whatever I committed to GitHub, this toolbox always compares it with what's in the target branch. This causes an issue and my expectation is that as long as any difference exists between the current commit and the last commit, it can be discovered.

Workflow yaml file:

on:
  workflow_dispatch:
  push:
    branches:
      - master
  pull_request:

jobs:
  deploy:
      name: Deploy
      runs-on: ubuntu-latest
      env:
        CLOUD_FORMATION_ROLE: my-role
     steps:
     - name: ECS_TASK_DEFINITIONCheckout
       uses: actions/checkout@v3
    - name: Get SHA of the prior commit
       id: prior-commit-sha
       run: |
         echo "pre=$(git rev-parse $GITHUB_SHA^1)" >> $GITHUB_ENV
    - name: Get changed files
       id: changed-files-specific
       uses: tj-actions/changed-files@v34
       with:
         fetch_depth: 1
         files: |
           my-directory/**
         base_sha: ${{ env.pre }}

Error trackrace:

Resolving repository path: /home/runner/work/my-repo/my-repo/.
  Retrieving changes between target-branch-SHA (poc-api) → source-branch-SHA (vendor-api)
  grep: : No such file or directory
  /home/runner/work/_actions/tj-actions/changed-files/v34/get-changed-paths.sh: line 66: echo: write error: Broken pipe
  Error: Process completed with exit code 1.

In the case above, I wasn't going to compare changes between target branch and source branch yet, instead, the current commit and the previous commit. How can I work around?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2022

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Nov 6, 2022

Hi @MemphisMeng, in order to give you an accurate answer can you enable debug logging and update the trace to include all information generated by the changed-files action.

@jackton1
Copy link
Member

jackton1 commented Nov 6, 2022

At first glance, I’ll also suggest you simplify your workflow file to use

on:
  workflow_dispatch:
  push:
     branches: '**'

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    env:
      CLOUD_FORMATION_ROLE: my-role
    steps:
     - name: ECS_TASK_DEFINITIONCheckout
       uses: actions/checkout@v3
       with: 
         fetch-depth: 2 
     - name: Get changed files
        id: changed-files-specific
        uses: tj-actions/changed-files@v34
        with:
          files: |
            my-directory/**

I’ll take a look at restoring the previous functionality to perform diffs between the last remote commit and the current HEAD.

@jackton1 jackton1 linked a pull request Nov 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants