Skip to content

Commit

Permalink
Create created-with-label.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jricciardi committed Jun 19, 2023
1 parent 9486cb5 commit 50e60d9
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/created-with-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 'created discussion action'

on:
discussion:
types: [created]

permissions:
contents: read
discussions: write

jobs:
action:
runs-on: ubuntu-latest
steps:
- name: Check if employee
id: check_employee
uses: actions/github-script@v6
with:
github-token: ${{ secrets.READ_GITHUB_ORG_MEMBERS_TOKEN }}
result-encoding: string
script: |
try {
const response = await github.rest.orgs.checkMembershipForUser({
org: `github`,
username: context.payload.sender.login
});
if (response.status === 204) {
return 'true';
} else {
return 'false';
}
} catch (error) {
console.log(error);
return 'false';
}
- name: Fetch discussion ID
id: fetch_discussion_id
if: ${{ steps.check_employee.outputs.result == 'true' && github.event.repository && github.event.discussion }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
gh api graphql -F owner=$OWNER -F name=$REPO -f query='
query($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
discussion(number: ${{ github.event.discussion.number }}) {
id
}
}
}' > discussion_data.json
echo 'DISCUSSION_ID='$(jq '.data.repository.discussion.id' discussion_data.json) >> $GITHUB_ENV
- name: UnLabel Discussion
if: ${{ steps.check_employee.outputs.result == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
config-path: '.github/label-actions.yml'

0 comments on commit 50e60d9

Please sign in to comment.