Skip to content

Commit

Permalink
chore: Create tag workflow updated
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalmahapatro committed Sep 4, 2023
1 parent 2ca6375 commit 40ec6a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/create_tag.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/trigger_on_pr_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.



Expand All @@ -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

0 comments on commit 40ec6a0

Please sign in to comment.