diff --git a/.github/filters.yml b/.github/filters.yml new file mode 100644 index 00000000000..2d607f7623f --- /dev/null +++ b/.github/filters.yml @@ -0,0 +1,9 @@ +gemfile: + - Gemfile + - Appraisals + - datadog.gemspec + - tasks/appraisal.rake + - .github/workflows/lock-dependency.yml + - lib/datadog/version.rb + - appraisal/** + - gemfiles/** diff --git a/.github/workflows/lock-dependency.yml b/.github/workflows/lock-dependency.yml index 1b977e1f241..e5ccc1b349b 100644 --- a/.github/workflows/lock-dependency.yml +++ b/.github/workflows/lock-dependency.yml @@ -1,15 +1,7 @@ name: Lock Dependency on: - workflow_dispatch: - inputs: - branch: - description: 'Branch to be lock dependency' - required: true - # Testing purpose, to be removed before merge. push: - branches: - - tonycthsu/automate-update-gemfiles # Ensure obsolete job is cancelled if another commit is pushed to the same branch. concurrency: @@ -17,10 +9,35 @@ concurrency: cancel-in-progress: true jobs: - # TODO: In order to fully automate this workflow for each PR, - # have a reliable way to precheck job to understand whether it need to be updated + pr: + runs-on: ubuntu-latest + outputs: + pr_found: ${{ steps.pr.outputs.pr_found }} + steps: + # Only execute if there's a PR attached to this branch. + # Because we execute on `push`, we have to double check here if this is part of a PR. + - name: Check if this branch is attached to a Pull Request + uses: 8BitJonny/gh-get-current-pr@3.0.0 + id: pr + with: + filterOutClosed: true # Don't trigger on commits with closed PRs, including merges into `master`. + dependency: + needs: pr + if: ${{ needs.pr.outputs.pr_found == 'true' }} + runs-on: ubuntu-latest + outputs: + changes: ${{ steps.changes.outputs.gemfile }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes + with: + base: ${{ github.ref_name }} + filters: .github/filters.yml lock: runs-on: ubuntu-latest + needs: dependency + if: ${{ needs.dependency.outputs.changes == 'true' }} strategy: fail-fast: false matrix: @@ -42,12 +59,12 @@ jobs: version: '2.6' - name: ruby version: '2.5' - - name: jruby - version: '9.4' - - name: jruby - version: '9.3' - - name: jruby - version: '9.2' + # - name: jruby + # version: '9.4' + # - name: jruby + # version: '9.3' + # - name: jruby + # version: '9.2' container: image: ghcr.io/datadog/images-rb/engines/${{ matrix.engine.name }}:${{ matrix.engine.version }} env: