From 40ec6a0a56e06402e1b354eb0fddd02840805202 Mon Sep 17 00:00:00 2001 From: kushalm Date: Tue, 5 Sep 2023 02:30:58 +0400 Subject: [PATCH] chore: Create tag workflow updated --- .github/workflows/create_tag.yml | 15 +++++-------- .github/workflows/trigger_on_pr_merge.yml | 27 ++++++++++++++++------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/create_tag.yml b/.github/workflows/create_tag.yml index bb8ff27..da2d39d 100644 --- a/.github/workflows/create_tag.yml +++ b/.github/workflows/create_tag.yml @@ -1,9 +1,6 @@ name: Create Tag and Publish to pub.dev on: - pull_request: - types: - - closed workflow_run: workflows: ["Trigger Create Tag and Publish Workflow on PR Merge", "Check Version"] types: @@ -22,10 +19,10 @@ jobs: secrets: TRIGGER_NEXT_ACTION: ${{ secrets.TRIGGER_NEXT_ACTION }} - call-trigger-create-tag-and-publish: - uses: ./.github/workflows/trigger_on_pr_merge.yml - secrets: - TRIGGER_CREATE_TAG_AND_PUBLISH: ${{ secrets.TRIGGER_CREATE_TAG_AND_PUBLISH }} + # call-trigger-create-tag-and-publish: + # uses: ./.github/workflows/trigger_on_pr_merge.yml + # secrets: + # TRIGGER_CREATE_TAG_AND_PUBLISH: ${{ secrets.TRIGGER_CREATE_TAG_AND_PUBLISH }} create-tag-and-publish: permissions: @@ -35,10 +32,10 @@ jobs: pull-requests: write runs-on: ubuntu-latest - needs: [placeholder-job, call-check-version, call-trigger-create-tag-and-publish] + needs: [placeholder-job, call-check-version] - if: ${{ needs.call-check-version.TRIGGER_NEXT_ACTION == 'true' && needs.call-trigger-create-tag-and-publish.TRIGGER_CREATE_TAG_AND_PUBLISH == 'true' }} + if: ${{needs.call-check-version.TRIGGER_NEXT_ACTION == 'true'}} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/trigger_on_pr_merge.yml b/.github/workflows/trigger_on_pr_merge.yml index 785b3ec..df11c9a 100644 --- a/.github/workflows/trigger_on_pr_merge.yml +++ b/.github/workflows/trigger_on_pr_merge.yml @@ -4,14 +4,14 @@ on: pull_request: types: - closed - workflow_call: - secrets: - TRIGGER_CREATE_TAG_AND_PUBLISH: - required: true - description: | - Set to true to trigger the Create Tag and Publish workflow. - Set to false to not trigger the Create Tag and Publish workflow. - Set to anything else to not trigger the Create Tag and Publish workflow. + # workflow_call: + # secrets: + # TRIGGER_CREATE_TAG_AND_PUBLISH: + # required: true + # description: | + # Set to true to trigger the Create Tag and Publish workflow. + # Set to false to not trigger the Create Tag and Publish workflow. + # Set to anything else to not trigger the Create Tag and Publish workflow. @@ -34,4 +34,15 @@ jobs: run: echo "set-env:TRIGGER_CREATE_TAG_AND_PUBLISH=${{ steps.check_merged.outputs.result}}" >> $GITHUB_ENV env: TRIGGER_CREATE_TAG_AND_PUBLISH: ${{ steps.check_merged.outputs.result}} + + - name: Trigger dependent workflow + run: | + if [ "${{ steps.check_merged.outputs.result }}" = "true" ]; then + curl -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/actions/workflows/create_tag.yml/dispatches \ + -d '{"ref": "main"}' + fi + \ No newline at end of file