|
| 1 | +name: 'Status Updater' |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + pull_request_target: |
| 6 | + |
| 7 | +jobs: |
| 8 | + set_statuses: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + if: ${{ !contains(github.event.issue.labels.*.name, 'manual') && !contains(github.event.pull_request.labels.*.name, 'manual') }} |
| 11 | + steps: |
| 12 | + - name: Get project data |
| 13 | + env: |
| 14 | + GH_TOKEN: ${{ secrets.TEST_TOKEN }} |
| 15 | + run: | |
| 16 | + echo "PROJECT_ID=$(gh project view 27 --owner tauri-apps --format json --jq '.id')" >> $GITHUB_ENV |
| 17 | + gh project field-list 27 --owner tauri-apps --format json > project_data.json |
| 18 | + echo 'STATUS_FIELD_ID='$(jq '.fields[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV |
| 19 | + echo 'BACKLOG_STATUS_ID='$(jq '.fields[] | select(.name== "Status") | .options[] | select(.name=="🪵 Backlog") | .id' project_data.json) >> $GITHUB_ENV |
| 20 | + echo 'READY_STATUS_ID='$(jq '.fields[] | select(.name== "Status") | .options[] | select(.name=="💪 Ready") | .id' project_data.json) >> $GITHUB_ENV |
| 21 | + echo 'IN_PROGRESS_STATUS_ID='$(jq '.fields[] | select(.name== "Status") | .options[] | select(.name=="🏗️ In progress") | .id' project_data.json) >> $GITHUB_ENV |
| 22 | + echo 'IN_REVIEW_STATUS_ID='$(jq '.fields[] | select(.name== "Status") | .options[] | select(.name=="📋 In review") | .id' project_data.json) >> $GITHUB_ENV |
| 23 | + echo 'DONE_STATUS_ID='$(jq '.fields[] | select(.name== "Status") | .options[] | select(.name=="✅ Done") | .id' project_data.json) >> $GITHUB_ENV |
| 24 | +
|
| 25 | + - name: Add project item / Get item id |
| 26 | + env: |
| 27 | + GH_TOKEN: ${{ secrets.TEST_TOKEN }} |
| 28 | + run: echo "ITEM_ID=$(gh project item-add 27 --owner tauri-apps --url https://github.com/tauri-apps/tauri-docs/issues/${{ github.event.pull_request.number || github.event.issue.number }} --format json --jq '.id')" >> $GITHUB_ENV |
| 29 | + |
| 30 | + #===== PULL REQUESTS =====# |
| 31 | + - name: Is In progress |
| 32 | + if: ${{ github.event_name == 'pull_request_target' && (github.event.pull_request.draft == true || github.event.pull_request.mergeable == false) }} |
| 33 | + run: echo 'STATUS_ID='${{ env.IN_PROGRESS_STATUS_ID }} >> $GITHUB_ENV |
| 34 | + |
| 35 | + - name: Is In review |
| 36 | + if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.draft == false && github.event.pull_request.mergeable == true }} |
| 37 | + run: echo 'STATUS_ID='${{ env.IN_REVIEW_STATUS_ID }} >> $GITHUB_ENV |
| 38 | + #===== END PULL REQUESTS =====# |
| 39 | + |
| 40 | + #===== ISSUES =====# |
| 41 | + - name: Is Ready |
| 42 | + if: ${{ github.event_name == 'issues' && (github.event.issue.labels[0] != null && github.event.issue.milestone != null) }} |
| 43 | + run: echo 'STATUS_ID='${{ env.READY_STATUS_ID }} >> $GITHUB_ENV |
| 44 | + |
| 45 | + - name: Is In progress |
| 46 | + if: ${{ github.event_name == 'issues' && (github.event.issue.labels[0] != null && github.event.issue.milestone != null && github.event.issue.assignees[0] != null) }} |
| 47 | + run: echo 'STATUS_ID='${{ env.IN_PROGRESS_STATUS_ID }} >> $GITHUB_ENV |
| 48 | + |
| 49 | + - name: Is In review |
| 50 | + if: ${{ github.event_name == 'issues' && (github.event.issue.labels[0] != null && github.event.issue.pull_request.merged_at != null) }} |
| 51 | + run: echo 'STATUS_ID='${{ env.IN_REVIEW_STATUS_ID }} >> $GITHUB_ENV |
| 52 | + |
| 53 | + - name: Is Backlog |
| 54 | + if: ${{ github.event_name == 'issues' && (github.event.issue.labels[0] == null || github.event.issue.milestone == null || contains(github.event.issue.labels.*.name, 'upstream') || contains(github.event.issue.labels.*.name, 'discuss')) }} |
| 55 | + run: echo 'STATUS_ID='${{ env.BACKLOG_STATUS_ID }} >> $GITHUB_ENV |
| 56 | + #===== END ISSUES =====# |
| 57 | + |
| 58 | + - name: Set fields |
| 59 | + env: |
| 60 | + GH_TOKEN: ${{ secrets.TEST_TOKEN }} |
| 61 | + run: gh project item-edit --id ${{ env.ITEM_ID }} --project-id ${{ env.PROJECT_ID }} --field-id ${{ env.STATUS_FIELD_ID }} --single-select-option-id ${{ env.STATUS_ID }} |
0 commit comments