Skip to content

Commit bb6543b

Browse files
committed
List of MorphoCloudWorkflow changes: ``` $ git shortlog dd76ebd..3e5163b --no-merges Jean-Christophe Fillion-Robin (1): feat: Add support for synchronous update of instance status issue label ``` See MorphoCloud/MorphoCloudWorkflow@dd76ebd...3e5163b
1 parent 9dea294 commit bb6543b

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

.github/actions/control-instance/action.yml

+9
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,12 @@ runs:
236236
`${{ inputs.command_name }}` command successfully applied to **${{ steps.define.outputs.instance_name }}** instance.
237237
238238
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
239+
240+
- name: Update Request Status Label
241+
if: ${{ always() }}
242+
uses: ./.github/actions/update-request-status-label
243+
with:
244+
os_cloud: ${{ inputs.os_cloud }}
245+
token: ${{ inputs.token }}
246+
instance_name: ${{ steps.define.outputs.instance_name }}
247+
issue_number: ${{ inputs.issue_number }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 }}

.github/workflows/create-instance.yml

+8
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ jobs:
420420
421421
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
422422
423+
- name: Update Request Status Label
424+
uses: ./.github/actions/update-request-status-label
425+
with:
426+
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
427+
token: ${{ secrets.GITHUB_TOKEN }}
428+
instance_name: ${{ steps.define.outputs.instance_name }}
429+
issue_number: ${{ github.event.issue.number }}
430+
423431
- name: comment (progress)
424432
uses: ./.github/actions/comment-progress
425433
with:

0 commit comments

Comments
 (0)