From 3cbaaa4795e338f192c7d9f6e165403396e94873 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 23 May 2023 20:55:35 +0200 Subject: [PATCH] Refactor and fix task trigger for dependent jobs in other repos (#4598) * Refactor and fix task trigger for dependent jobs in other repos I have confirmed (https://github.com/konstin/ruff-pre-commit/actions/runs/5056928280/jobs/9075029868) that this does dispatch the workflow when running with act, `owner: 'konstin'`, `needs` commented out and personal access token. I can't properly test the actual release workflow, and i'm unsure how to best handle the next release after this was merged (should we do a beta release or will this break everything that assumes we only do stable releases?) The command for act is ``` act -j update-dependents -s RUFF_PRE_COMMIT_PAT=<...> ``` * delete old file --- .github/workflows/release.yaml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6d0bda1142..ecd14f052f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,7 @@ name: "[ruff] Release" on: workflow_dispatch: release: - types: [published] + types: [ published ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -406,9 +406,6 @@ jobs: run: | pip install --upgrade twine twine upload --skip-existing * - - name: "Update pre-commit mirror" - run: | - curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.RUFF_PRE_COMMIT_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/astral-sh/ruff-pre-commit/dispatches --data '{"event_type": "pypi_release"}' - uses: actions/download-artifact@v3 with: name: binaries @@ -417,3 +414,22 @@ jobs: uses: softprops/action-gh-release@v1 with: files: binaries/* + + # After the release has been published, we update downstream repositories + # This is separate because if this fails the release is still fine, we just need to do some manual workflow triggers + update-dependents: + name: Release + runs-on: ubuntu-latest + needs: release + steps: + - name: "Update pre-commit mirror" + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.RUFF_PRE_COMMIT_PAT }} + script: | + github.rest.actions.createWorkflowDispatch({ + owner: 'astral-sh', + repo: 'ruff-pre-commit', + workflow_id: 'main.yml', + ref: 'main', + })