Skip to content

Commit

Permalink
chore: fix validations in workflows (#1982)
Browse files Browse the repository at this point in the history
* chore: log gh api response

* chore: fix response assertion

* chore: fix conditions in workflows for actor validations
  • Loading branch information
saikumarrs authored Dec 27, 2024
1 parent fcb2dca commit c5b8cb8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
validate-actor:
# Run only for workflow_dispatch events with a merged pull request
# Run only for workflow_dispatch events
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/validate-actor.yml
secrets:
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/deploy-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ env:

jobs:
validate-actor:
# Run validation for workflow_dispatch with tags
if: >
github.event_name == 'workflow_dispatch' &&
startsWith(github.ref, 'refs/tags/v')
# Run validation for workflow_dispatch
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/validate-actor.yml
secrets:
PAT: ${{ secrets.PAT }}
Expand All @@ -42,7 +40,14 @@ jobs:
# Deploy if validate-actor was successful or skipped
# or if the workflow was invoked by another workflow
if: >
(needs.validate-actor.result == 'success' || needs.validate-actor.result == 'skipped') || inputs.is_called == 'true'
(needs.validate-actor.result == 'success' || needs.validate-actor.result == 'skipped') &&
(
inputs.is_called == 'true' ||
(
github.event_name == 'workflow_dispatch' &&
startsWith(github.ref, 'refs/tags/v')
)
)
steps:
- name: Checkout
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ on:

jobs:
validate-actor:
if: >
github.event_name == 'workflow_dispatch' &&
(
startsWith(github.ref, 'refs/tags/v') ||
startsWith(github.head_ref, 'hotfix-release/') ||
startsWith(github.head_ref, 'release/')
)
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/validate-actor.yml
secrets:
PAT: ${{ secrets.PAT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-actor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fi
# Extract the state of the membership
if echo "$response" | grep -q '"state": "active"'; then
if echo "$response" | grep -q '"state":"active"'; then
echo "'$actor' is a member of '@${ORG_NAME}/${TEAM_NAME}' team"
else
echo "Error: '$actor' is NOT a member of '@${ORG_NAME}/${TEAM_NAME}' team. Access denied."
Expand Down

0 comments on commit c5b8cb8

Please sign in to comment.