4 types: [opened, reopened]
6 types: [opened, reopened, synchronize]
9 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10 cancel-in-progress: true
16 runs-on: ubuntu-latest
17 if: github.repository == 'ohmyzsh/ohmyzsh'
19 GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
21 - name: Read project data
27 gh api graphql -f query='
28 query($org: String!, $number: Int!) {
29 organization(login: $org){
30 projectNext(number: $number) {
41 ' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
44 cat >> $GITHUB_ENV <<EOF
45 PROJECT_ID=$(jq '.data.organization.projectNext.id' project_data.json)
46 PLUGIN_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
47 THEME_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
50 - name: Add to project
52 ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
54 item_id="$(gh api graphql -f query='
55 mutation($project: ID!, $content: ID!) {
56 addProjectNextItem(input: {projectId: $project, contentId: $content}) {
62 ' -f project=$PROJECT_ID -f content=$ISSUE_OR_PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
64 echo "ITEM_ID=$item_id" >> $GITHUB_ENV
66 - name: Classify Pull Request
67 if: github.event_name == 'pull_request_target'
69 touch plugins.list themes.list
71 gh pr view ${{ github.event.pull_request.number }} \
72 --repo ${{ github.repository }} \
73 --json files --jq '.files.[].path' | awk -F/ '
78 gsub(/\.zsh-theme$/, "", $2)
82 for (plugin in plugins) {
83 print plugin >> "plugins.list"
85 for (theme in themes) {
86 print theme >> "themes.list"
90 # If only one plugin is modified, add it to the plugin field
91 if [[ $(wc -l < plugins.list) = 1 ]]; then
92 echo "PLUGIN=$(cat plugins.list)" >> $GITHUB_ENV
94 # If only one theme is modified, add it to the theme field
95 if [[ $(wc -l < themes.list) = 1 ]]; then
96 echo "THEME=$(cat themes.list)" >> $GITHUB_ENV
99 - name: Fill Pull Request fields in project
100 if: github.event_name == 'pull_request_target'
102 gh api graphql -f query='
107 $plugin_value: String!
109 $theme_value: String!
111 set_plugin: updateProjectNextItemField(input: {
114 fieldId: $plugin_field
121 set_theme: updateProjectNextItemField(input: {
124 fieldId: $theme_field
132 ' -f project=$PROJECT_ID -f item=$ITEM_ID \
133 -f plugin_field=$PLUGIN_FIELD_ID -f plugin_value=$PLUGIN \
134 -f theme_field=$THEME_FIELD_ID -f theme_value=$THEME \