From d5de7840fb114fd6e320261cc09b958698087aed Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 12 Feb 2025 17:56:19 -0300 Subject: [PATCH] chore(dependabot): ask repo name as input, copy workflow as well --- .github/workflows/dependabot-sync.yml | 16 +++++++++++----- dependabot/workflows/dependabot-sync.yml | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 dependabot/workflows/dependabot-sync.yml diff --git a/.github/workflows/dependabot-sync.yml b/.github/workflows/dependabot-sync.yml index 9ae94ab..ba25983 100644 --- a/.github/workflows/dependabot-sync.yml +++ b/.github/workflows/dependabot-sync.yml @@ -1,6 +1,11 @@ name: dependabot-sync on: workflow_call: + inputs: + repo_name: + description: The repository name, without the "charmbracelet/" prefix. + required: true + type: string permissions: contents: write @@ -12,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - path: ${{ github.repository }} + path: ${{ github.repository_owner }}/${{ inputs.repo_name }} - uses: actions/checkout@v4 with: @@ -20,10 +25,11 @@ jobs: path: ${{ github.repository_owner }}/meta - run: | - cp "${{ github.repository_owner }}/meta/dependabot/dependabot.yml" "${{ github.repository }}/dependabot.yml" - DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot-${{ github.event.repository.name }}.yml" + cp "${{ github.repository_owner }}/meta/dependabot/workflows/dependabot-sync.yml" "${{ github.repository_owner }}/${{ inputs.repo_name }}/.github/workflows/dependabot-sync.yml" + cp "${{ github.repository_owner }}/meta/dependabot/dependabot.yml" "${{ github.repository_owner }}/${{ inputs.repo_name }}/dependabot.yml" + DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot-${{ inputs.repo_name }}.yml" if [ -f "$DEPENDABOT_FILE" ]; then - cat "$DEPENDABOT_FILE" >> "${{ github.repository }}/dependabot.yml" + cat "$DEPENDABOT_FILE" >> "${{ github.repository_owner }}/${{ inputs.repo_name }}/dependabot.yml" fi - name: Create Pull Request @@ -36,7 +42,7 @@ jobs: This is an automated pull request to sync the Dependabot config with the meta repository. branch: "ci/sync-dependabot-config" delete-branch: true - path: "${{ github.repository }}" + path: "${{ github.repository_owner }}/${{ inputs.repo_name }}" - name: Check outputs if: ${{ steps.cpr.outputs.pull-request-number }} diff --git a/dependabot/workflows/dependabot-sync.yml b/dependabot/workflows/dependabot-sync.yml new file mode 100644 index 0000000..e5aa74e --- /dev/null +++ b/dependabot/workflows/dependabot-sync.yml @@ -0,0 +1,15 @@ +name: dependabot-sync +on: + schedule: + - cron: "0 0 * * 0" # every Sunday at midnight + workflow_dispatch: # allows manual triggering + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot-sync: + uses: charmbracelet/meta/.github/workflows/dependabot-sync.yml@main + with: + repo_name: ${{ github.event.repository.name }}