Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Language label on project with language label on the issue #4821

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .github/workflows/project-auto-add.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:

echo 'ITEM_ID='$item_id >> $GITHUB_ENV

- name: Set Language
- name: Set Language to Project
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
Expand All @@ -108,3 +108,42 @@ jobs:
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f language_field=$LANGUAGE_FIELD_ID -f language_value=${{ env.LANGUAGE_OPTION_ID }} --silent

- name: Get label for selected language in repository
if: ${{ env.SELECTED_LANGUAGE != 'Multiple Languages'}}
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh api graphql -f query='
query($repoOwner: String!, $repoName: String!) {
repository(owner: $repoOwner, name: $repoName) {
id,
labels(first: 100) {
nodes{
id,
name
}
}
}
}' -f repoOwner=${{github.repository_owner}} -f repoName=${{github.event.repository.name}} > issue_data.json

echo 'LANGUAGELABEL_ID='$(jq --arg lang "$SELECTED_LANGUAGE" '.data.repository.labels.nodes[] | select(.name==$lang) | .id' issue_data.json) >> $GITHUB_ENV

- name: Add label to issue
if: ${{ env.SELECTED_LANGUAGE != 'Multiple Languages'}}
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUE_ID: ${{ github.event_name == 'issues' && github.event.issue.node_id || github.event.pull_request.node_id }}
run: |
gh api graphql -f query='
mutation (
$issue: ID!
$label: ID!
) {
addLabelsToLabelable(input: {
labelableId: $issue
labelIds : [$label]
}) {
clientMutationId
}
}' -f issue=$ISSUE_ID -f label=$LANGUAGELABEL_ID --silent
Loading