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

feat(workflow): update workflow to add date field #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
120 changes: 98 additions & 22 deletions .github/workflows/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Add new issues to PatternFly Extensions project

on:
Expand All @@ -18,24 +17,101 @@ jobs:
label-issue:
runs-on: ubuntu-latest
steps:
- name: Team Membership Checker
# You may pin to the exact commit or the version.
# uses: TheModdingInquisition/actions-team-membership@a69636a92bc927f32c3910baac06bacc949c984c
uses: TheModdingInquisition/[email protected]
with:
# Repository token. GitHub Action token is used by default(recommended). But you can also use the other token(e.g. personal access token).
token: ${{ secrets.GH_READ_ORG_TOKEN }}
# The team to check for.
team: 'frequent-flyers'
# The organization of the team to check for. Defaults to the context organization.
organization: 'patternfly'
# If the action should exit if the user is not part of the team.
exit: true

- name: Add label if user is a team member
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
-d '{"labels":["PF Team"]}'
- name: Team Membership Checker
# You may pin to the exact commit or the version.
# uses: TheModdingInquisition/actions-team-membership@a69636a92bc927f32c3910baac06bacc949c984c
uses: TheModdingInquisition/[email protected]
with:
# Repository token. GitHub Action token is used by default(recommended). But you can also use the other token(e.g. personal access token).
token: ${{ secrets.GH_READ_ORG_TOKEN }}
# The team to check for.
team: 'frequent-flyers'
# The organization of the team to check for. Defaults to the context organization.
organization: 'patternfly'
# If the action should exit if the user is not part of the team.
exit: true

- name: Add label if user is a team member
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
-d '{"labels":["PF Team"]}'
track-issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORGANIZATION: patternfly
PROJECT_NUMBER: 7
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org) {
projectV2(number: $number) {
id
fields(first:20) {
nodes {
... on ProjectV2Field {
id
name
}
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json

echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Date added") | .id' project_data.json) >> $GITHUB_ENV

- name: Add issue to project & get project issue id
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_ID: ${{ github.event.issue.number }}
run: |
item_id="$(gh api graphql -f query='
mutation($project: ID!, $issue: ID!) {
addProjectV2ItmById(input: { projectId: $project, contentId: $issue }) {
item { id }
}
}
' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')"

echo 'ITEM_ID='$item_id >> $GITHUB_ENV

- name: Get date
run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV

- name: Set project fields
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api graphql -f query='
mutation(
$project: ID!,
$item: ID!,
$date_field: ID!,
$date_value: Date!
) {
set_date_added: updateProjectV2ItemFieldValue(input: {
projectId: $project,
itemId: $item,
fieldId: $date_field,
value: {
date: $date_value
}
}) {
projectV2Item { id }
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE --silent
Loading