|
| 1 | +name: "Update Request Status Label" |
| 2 | +description: "Update Request Status Label" |
| 3 | +inputs: |
| 4 | + os_cloud: |
| 5 | + description: |
| 6 | + "Name of the OpenStack cloud allocation to select openstack auth settings |
| 7 | + defined in '.config/openstack/clouds.yaml'" |
| 8 | + required: true |
| 9 | + token: |
| 10 | + description: "GITHUB_TOKEN or repo scoped PAT" |
| 11 | + required: true |
| 12 | + issue_number: |
| 13 | + description: "Issue number" |
| 14 | + required: true |
| 15 | + instance_name: |
| 16 | + description: "Instance name" |
| 17 | + required: true |
| 18 | +runs: |
| 19 | + using: "composite" |
| 20 | + steps: |
| 21 | + - name: Retrieve instance status |
| 22 | + id: retrieve_instance_status |
| 23 | + shell: bash |
| 24 | + run: | |
| 25 | + source ~/venv/bin/activate |
| 26 | +
|
| 27 | + echo Retrieving instance "$INSTANCE_NAME" status |
| 28 | +
|
| 29 | + # Get instance status |
| 30 | + instance_status=$( |
| 31 | + openstack server show $INSTANCE_NAME -c status -f json | \ |
| 32 | + jq -r .status |
| 33 | + ) |
| 34 | + echo "instance_status [$instance_status]" |
| 35 | + echo "instance_status=$instance_status" >> $GITHUB_OUTPUT |
| 36 | + env: |
| 37 | + INSTANCE_NAME: ${{ inputs.instance_name }} |
| 38 | + |
| 39 | + - name: Update issues |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + issue_number=$ISSUE_NUMBER |
| 43 | + status_lowercase=${$INSTANCE_STATUS,,} |
| 44 | +
|
| 45 | + add_label="status:$status_lowercase" |
| 46 | +
|
| 47 | + remove_labels=$(gh issue view $issue_number --json labels | \ |
| 48 | + jq \ |
| 49 | + -r \ |
| 50 | + --arg add_label "$add_label" \ |
| 51 | + -c '[.labels[].name | select(test("^status:")?) | select(. != $add_label)] | join(",")') |
| 52 | +
|
| 53 | + echo "Updating issue $issue_number adding label [$add_label] and removing labels [$remove_labels]" |
| 54 | +
|
| 55 | + gh issue edit ${issue_number} --add-label "${add_label}" --remove-label "${remove_labels}" |
| 56 | + env: |
| 57 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + ISSUE_NUMBER: ${{ inputs.issue_number }} |
| 59 | + INSTANCE_STATUS: |
| 60 | + ${{ steps.get_instance_status.outputs.instance_status }} |
0 commit comments