Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
List of MorphoCloudWorkflow changes:

```
$ git shortlog dd76ebd..8d38624 --no-merges
Jean-Christophe Fillion-Robin (1):
      feat: Add support for synchronous update of instance status issue label
```

See MorphoCloud/MorphoCloudWorkflow@dd76ebd...8d38624
  • Loading branch information
jcfr committed Sep 13, 2024
1 parent 9dea294 commit fa810b3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/actions/control-instance/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,12 @@ runs:
`${{ inputs.command_name }}` command successfully applied to **${{ steps.define.outputs.instance_name }}** instance.
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Update Request Status Label
if: ${{ always() }}
uses: ./.github/actions/update-request-status-label
with:
os_cloud: ${{ inputs.os_cloud }}
token: ${{ inputs.token }}
instance_name: ${{ steps.define.outputs.instance_name }}
issue_number: ${{ inputs.issue_number }}
60 changes: 60 additions & 0 deletions .github/actions/update-request-status-label/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Update Request Status Label"
description: "Update Request Status Label"
inputs:
os_cloud:
description:
"Name of the OpenStack cloud allocation to select openstack auth settings
defined in '.config/openstack/clouds.yaml'"
required: true
token:
description: "GITHUB_TOKEN or repo scoped PAT"
required: true
issue_number:
description: "Issue number"
required: true
instance_name:
description: "Instance name"
required: true
runs:
using: "composite"
steps:
- name: Retrieve instance status
id: retrieve_instance_status
shell: bash
run: |
source ~/venv/bin/activate
echo Retrieving instance "$INSTANCE_NAME" status
# Get instance status
instance_status=$(
openstack server show $INSTANCE_NAME -c status -f json | \
jq -r .status
)
echo "instance_status [$instance_status]"
echo "instance_status=$instance_status" >> $GITHUB_OUTPUT
env:
INSTANCE_NAME: ${{ inputs.instance_name }}

- name: Update issues
shell: bash
run: |
issue_number=$ISSUE_NUMBER
status_lowercase=${$INSTANCE_STATUS,,}
add_label="status:$status_lowercase"
remove_labels=$(gh issue view $issue_number --json labels | \
jq \
-r \
--arg add_label "$add_label" \
-c '[.labels[].name | select(test("^status:")?) | select(. != $add_label)] | join(",")')
echo "Updating issue $issue_number adding label [$add_label] and removing labels [$remove_labels]"
gh issue edit ${issue_number} --add-label "${add_label}" --remove-label "${remove_labels}"
env:
GH_TOKEN: ${{ inputs.token }}
ISSUE_NUMBER: ${{ inputs.issue_number }}
INSTANCE_STATUS:
${{ steps.get_instance_status.outputs.instance_status }}
8 changes: 8 additions & 0 deletions .github/workflows/create-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ jobs:
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Update Request Status Label
uses: ./.github/actions/update-request-status-label
with:
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
token: ${{ secrets.GITHUB_TOKEN }}
instance_name: ${{ steps.define.outputs.instance_name }}
issue_number: ${{ github.event.issue.number }}

- name: comment (progress)
uses: ./.github/actions/comment-progress
with:
Expand Down

0 comments on commit fa810b3

Please sign in to comment.