derberg / manage-files-in-multiple-repositories

GitHub Action that introduces support for global workflows. Global workflows are the one you update in just one repo and they are automatically updated in other repositories.
MIT License
51 stars 18 forks source link

no changes detected #39

Closed ReenigneArcher closed 1 year ago

ReenigneArcher commented 2 years ago

Describe the bug

A clear and concise description of what the bug is.

When running the workflow I get a message "no changes detected".

How to Reproduce

Steps to reproduce the issue. Attach all resources that can help us understand the issue:

name: Global replicator

on:
  push:
    branches: [master]
    paths:
      - ".github/**"
      - "dependabot/**"
      - "gitignore/**"
  workflow_dispatch:
    inputs:
      repo_name:
        description: |
          You can specify the repository's name where workflows should be pushed manually, as long as workflow settings do not ignore the repository.
          If you do not specify the exact repository name, the workflow will try to replicate all missing changes to all repositories.
        required: false

jobs:
  replicate:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false  # false to run all, true to fail entire job if any fail
      matrix:
        include:
        - job_name: 'workflows'
          patterns_to_ignore: ''
          patterns_to_include: '.github/label-actions.yml,.github/workflows/automerge.yml,.github/workflows/issues.yml,.github/workflows/issues-stale.yml,.github/workflows/pull-requests.yml'
          commit_message: 'ci: update global workflows'
          repos_to_ignore: ''
          topics_to_include: ''
          exclude_private: false
          exclude_forked: true
          branches: 'nightly'
          destination: ''
        - job_name: 'dependabot for github-actions'
          patterns_to_ignore: ''
          patterns_to_include: 'dependabot/github-actions/dependabot.yml'
          commit_message: 'ci: update dependabot'
          repos_to_ignore: ''
          topics_to_include: 'replicator-dependabot-basic'
          exclude_private: false
          exclude_forked: true
          branches: 'nightly'
          destination: '.github'
        - job_name: 'dependabot for python'
          patterns_to_ignore: ''
          patterns_to_include: 'dependabot/pip/dependabot.yml'
          commit_message: 'ci: update dependabot'
          repos_to_ignore: ''
          topics_to_include: 'replicator-dependabot-pip'
          exclude_private: false
          exclude_forked: true
          branches: 'nightly'
          destination: '.github'
        - job_name: 'custom issues'
          patterns_to_ignore: ''
          patterns_to_include: '.github/ISSUE_TEMPLATE/config.yml'
          commit_message: 'ci: update issue templates'
          repos_to_ignore: ''
          topics_to_include: 'replicator-custom-issues'
          exclude_private: false
          exclude_forked: true
          branches: 'nightly'
          destination: ''
        - job_name: 'release notifier'
          patterns_to_ignore: ''
          patterns_to_include: '.github/workflows/release_notifier.yml'
          commit_message: 'ci: update release notifier'
          repos_to_ignore: ''
          topics_to_include: 'replicator-release-notifications'
          exclude_private: false
          exclude_forked: true
          branches: 'nightly'
          destination: ''

    name: ${{ matrix.job_name }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Replicating files
        uses: derberg/copy-files-to-other-repositories@v1
        with:
          github_token: ${{ secrets.GH_PAT }}
          committer_username: RetroArcher-bot
          committer_email: something@something.com
          patterns_to_ignore: ${{ matrix.patterns_to_ignore }}
          patterns_to_include: ${{ matrix.patterns_to_include }}
          commit_message: ${{ matrix.commit_message }}
          repos_to_ignore: ${{ matrix.repos_to_ignore }}
          topics_to_include: ${{ matrix.topics_to_include }}
          exclude_private: ${{ matrix.exclude_private }}
          exclude_forked: ${{ matrix.exclude_forked }}
          branches: ${{ matrix.branches }}
          destination: ${{ matrix.destination }}

Expected behavior

A clear and concise description of what you expected to happen.

The workflow should compare the files found by "patterns" to the files in the destination repositories. If they don't match exactly it should create the PR in the destination repository.

ReenigneArcher commented 2 years ago

Also, another major issue.

I ran this manually, and it pushed changes to branches that it definitely should not do.

image

Thankfully it only modified dependabot PRs which are easy to recreate.

Am I misunderstanding the purpose of this action?

It also never created a PR against nightly which is what I would have expected to happen.

Luckily github prevented this from going too crazy: https://github.com/RetroArcher/.github/runs/7163456889?check_suite_focus=true

Edit: I see that the branches use regex, so I will switch it to ^nightly$ which I believe will only match nightly exactly.

ReenigneArcher commented 2 years ago

Using ^nightly$ for the branches does indeed solve the problem of pushing to the dependabot branches. Note this was in combination with an automerge workflow as suggested in the readme. I've also added BASE_BRANCHES: nightly to the automerge action to prevent any accidental automatic merges.

But going back to the original issue. I guess the workflow caches the changes? Can you add an option to disable the cache? I would like to run this on a schedule if possible, but it currently does nothing if there is a cache.

Problems with using the cache:

derberg commented 2 years ago

@ReenigneArcher thanks a lot for taking time to report such a detailed issue šŸ™šŸ¼

I guess the workflow caches the changes

there is no caching done in the action

I would like to run this on a schedule if possible

for now it works on push and workflow_dispatch. I think supporting schedule should not be very complex, as to my knowledge, it would work completely the same way workflow_dispatch is. Please create separate issue so we do not mix to many concerns in the same issue.


regarding the original problem, the link that you shared: https://github.com/RetroArcher/.github/runs/7163398223 it actually points to https://github.com/RetroArcher/.github/commit/199d96607a3a1cc486155ed20603e1446c42a68d and there were really no changes related to workflows other than the global one

the action works in the way that it picks up only files that were modified with a given commit, and not all files -> https://github.com/derberg/copy-files-to-other-repositories/blob/main/lib/utils.js#L23-L29

only in case of workflow_dispatch we take all -> https://github.com/derberg/copy-files-to-other-repositories/blob/main/lib/utils.js#L31-L35

there are basically 2 use cases, you want to replicate all changes in all repos (or just selected one) on demand using workflow_dispatch or you just want to replicate changes that came with a given commit. I hope that makes sense

ReenigneArcher commented 2 years ago

I misunderstood the manual workflow run. I did not realize if no repo was supplied it would run against all.

Do I understand correctly, that if I run on a schedule it will behave the same as running as workflow dispatch with no repository supplied?

derberg commented 2 years ago

Do I understand correctly, that if I run on a schedule it will behave the same as running as workflow dispatch with no repository supplied?

I answered:

for now it works on push and workflow_dispatch. I think supporting schedule should not be very complex, as to my knowledge, it would work completely the same way workflow_dispatch is. Please create separate issue so we do not mix to many concerns in the same issue.

for now, if you use schedule, you will get error like: 'This GitHub Action works only when triggered by "push" or "workflow_dispatch" webhooks.'

ReenigneArcher commented 2 years ago

Okay, thanks for the clarification. Originally, I wasn't sure if you were referring to the action or my workflow yaml. Thanks.

derberg commented 1 year ago

Looks like answered and therefore solved.

Closing, lemme know if I'm wrong