Skip to content

Commit

Permalink
Add conditional steps due to context errors (NVIDIA#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmak-nv authored and alliepiper committed Aug 30, 2023
1 parent 558198e commit bcac53d
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions .github/workflows/project_automation_set_in_progress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,41 @@ jobs:
steps:
- name: Check if changes requested from a reviewer
id: check_changes_requested
if: github.event_name == 'pull_request_review'
run: |
if [ ${{ github.event_name }} == 'pull_request_review' ]; then
if [ ${{ github.event.review.state }} != 'changes_requested' ]; then
echo "Changes not requested, exiting"
exit 0
# If it is requesting changes, set PR to draft
# We use the default token here since we're granting write access to the PR
elif [ ${{ github.event.pull_request.draft }} == true ]; then
gh api graphql -f query='
mutation {
convertPullRequestToDraft(input: {pullRequestId: "${{ env.PR_GLOBAL_ID }}"}) {
clientMutationId
}
}'
exit 0
fi
if [ ${{ github.event.review.state }} != 'changes_requested' ]; then
echo "Changes not requested, exiting"
exit 0
# If it is requesting changes, set PR to draft
# We use the default token here since we're granting write access to the PR
elif [ ${{ github.event.pull_request.draft }} == true ]; then
gh api graphql -f query='
mutation {
convertPullRequestToDraft(input: {pullRequestId: "${{ env.PR_GLOBAL_ID }}"}) {
clientMutationId
}
}'
exit 0
fi
continue-on-error: true

- name: Generate token
id: generate_token
if: github.event_name == 'pull_request_target'
uses: tibdex/github-app-token@v1.8.0
with:
app_id: ${{ secrets.CCCL_AUTH_APP_ID }}
private_key: ${{ secrets.CCCL_AUTH_APP_PEM }}

- name: Wait 1 Second
id: sleep
if: github.event_name == 'pull_request_target'
run: sleep 1

- name: Get PR Project ID
id: get_pr_id
if: github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
Expand Down Expand Up @@ -120,6 +122,7 @@ jobs:

- name: Set PR Fields
id: set_pr_fields
if: github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
Expand Down Expand Up @@ -249,6 +252,7 @@ jobs:

- name: Sync Linked Issues
id: sync_linked_issues
if: github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
Expand Down

0 comments on commit bcac53d

Please sign in to comment.