-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update to MorphoCloud/MorphoCloudWorkflow@73967cf
List of MorphoCloudWorkflow changes: ``` $ git shortlog b303508..73967cf --no-merges Jean-Christophe Fillion-Robin (2): feat: Rename command from "/delete" to "/delete_instance" feat: Add support for /delete_volume command ``` See MorphoCloud/MorphoCloudWorkflow@b303508...73967cf
- Loading branch information
Showing
3 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
name: "Delete Volume" | ||
description: "Delete Volume" | ||
inputs: | ||
os_cloud: | ||
description: | ||
"Name of the OpenStack cloud allocation to select openstack auth settings | ||
defined in '.config/openstack/clouds.yaml'" | ||
required: true | ||
issue_number: | ||
description: "Issue number" | ||
required: true | ||
instance_name_prefix: | ||
description: "Instance name prefix" | ||
required: true | ||
volume_name_suffix: | ||
description: "Volume name suffix" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Define volume name | ||
id: define_volume_name | ||
uses: ./.github/actions/define-volume-name | ||
with: | ||
issue_number: ${{ inputs.issue_number }} | ||
suffix: ${{ inputs.volume_name_suffix }} | ||
|
||
- name: Check volume exists | ||
id: check_volume | ||
uses: ./.github/actions/check-volume-exists | ||
with: | ||
os_cloud: ${{ inputs.os_cloud }} | ||
volume_name: ${{ steps.define_volume_name.outputs.volume_name }} | ||
|
||
- name: comment (volume does not exist) | ||
if: ${{ steps.check_volume.outputs.exists == 'false' }} | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
### Command Results ❌ | ||
`/delete_volume` command failed because **${{ steps.define_volume_name.outputs.volume_name }}** volume does not exist. | ||
- name: Define instance name | ||
id: define | ||
uses: ./.github/actions/define-instance-name | ||
with: | ||
prefix: ${{ inputs.instance_name_prefix }} | ||
issue_number: ${{ inputs.issue_number }} | ||
|
||
- name: Check instance exists | ||
id: check_instance | ||
uses: ./.github/actions/check-instance-exists | ||
with: | ||
os_cloud: ${{ inputs.os_cloud }} | ||
instance_name: ${{ steps.define.outputs.instance_name }} | ||
|
||
- name: Detach Volume | ||
if: ${{ steps.check_instance.outputs.exists == 'true' }} | ||
id: detach_volume | ||
shell: bash | ||
run: | | ||
source ~/venv/bin/activate | ||
volume_id=$(openstack volume list -f json | \ | ||
jq \ | ||
--arg volume_name "$VOLUME_NAME" \ | ||
-c '.[] | select(.Name == $volume_name)' | \ | ||
jq -r '.ID' | tail -1) | ||
echo "volume_id [$volume_id]" | ||
instance_id=$(openstack server list -f json | \ | ||
jq \ | ||
--arg instance_name "$INSTANCE_NAME" \ | ||
-c '.[] | select(.Name == $instance_name)' | \ | ||
jq -r '.ID' | tail -1) | ||
echo "instance_id [$instance_id]" | ||
openstack server remove volume \ | ||
$instance_id \ | ||
$volume_id | ||
env: | ||
OS_CLOUD: ${{ inputs.os_cloud }} | ||
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }} | ||
VOLUME_NAME: ${{ steps.define_volume_name.outputs.volume_name }} | ||
|
||
- name: comment (failed to detach volume) | ||
if: ${{ steps.detach_volume.outcome == 'failure' && failure() }} | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
### Command Results ❌ | ||
Failed to detach volume **${{ steps.define_volume_name.outputs.volume_name }}** | ||
from instance **${{ steps.define_volume_name.outputs.volume_name }}**. | ||
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
- name: Delete Volume | ||
id: delete_volume | ||
shell: bash | ||
run: | | ||
source ~/venv/bin/activate | ||
volume_id=$(openstack volume list -f json | \ | ||
jq \ | ||
--arg volume_name "$VOLUME_NAME" \ | ||
-c '.[] | select(.Name == $volume_name)' | \ | ||
jq -r '.ID' | tail -1) | ||
echo "volume_id [$volume_id]" | ||
openstack volume delete $volume_id | ||
env: | ||
OS_CLOUD: ${{ inputs.os_cloud }} | ||
VOLUME_NAME: ${{ steps.define_volume_name.outputs.volume_name }} | ||
|
||
- name: comment (failed to delete volume) | ||
if: ${{ steps.delete_volume.outcome == 'failure' && failure() }} | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
### Command Results ❌ | ||
Failed to delete volume **${{ steps.define_volume_name.outputs.volume_name }}**. | ||
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
- name: command results comment (success) | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ inputs.issue_number }} | ||
body: | | ||
### Command Results ✅ | ||
Volume **${{ steps.define_volume_name.outputs.volume_name }}** successfully deleted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Delete Volume | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
create: | ||
runs-on: self-hosted | ||
if: | ||
${{ !github.event.issue.pull_request && ( | ||
contains(github.event.comment.body, '/delete_volume') ) }} | ||
steps: | ||
- name: delete_volume command | ||
id: delete_volume_command | ||
uses: github/[email protected] | ||
with: | ||
command: "/delete_volume" | ||
reaction: "rocket" | ||
allowed_contexts: "issue" | ||
permissions: "write,maintain,admin" | ||
allowlist: "${{ vars.MORPHOCLOUD_GITHUB_ADMINS }}" | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Delete volume | ||
id: delete_volume | ||
if: ${{ steps.delete_volume_command.outputs.continue == 'true' }} | ||
uses: ./.github/actions/delete-volume | ||
with: | ||
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }} | ||
issue_number: ${{ github.event.issue.number }} | ||
instance_name_prefix: ${{ vars.INSTANCE_NAME_PREFIX }} | ||
volume_name_suffix: ${{ vars.VOLUME_NAME_SUFFIX }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters