Skip to content

Commit

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

```
$ git shortlog b77ee9f..60b6be5 --no-merges
Jean-Christophe Fillion-Robin (8):
      feat: Set openstack cloud name through repository variable
      doc(README): Document how to setup GitHub project and GitHub runner
      feat: Set "github/command" allowlist through repository variable
      feat: Support setting GitHub admin emails through repository variable
      fix: Limit concurrent runs of the same scheduled workflow
      doc(README): Update instructions to setup runner to include GitHub CLI
      fix(actions/control-instance): Add missing "os_cloud" input
      doc(README): Fix runner instructions to grant instance user access to docker
```

See MorphoCloud/MorphoCloudWorkflow@b77ee9f...60b6be5
  • Loading branch information
jcfr committed Sep 11, 2024
1 parent f6eb1a9 commit 55e5c0b
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 39 deletions.
8 changes: 6 additions & 2 deletions .github/actions/check-instance-exists/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Check instance exists"
description: "Check instance exists"
inputs:
os_cloud:
description:
"Name of the OpenStack cloud allocation to select openstack auth settings
defined in '.config/openstack/clouds.yaml'"
required: true
instance_name:
description: "Name of the instance"
required: true
Expand All @@ -15,8 +20,6 @@ runs:
id: check_instance
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
instance=$(openstack server list -f json | \
Expand All @@ -30,4 +33,5 @@ runs:
echo "exists [$exists]"
echo "exists=$exists" >> $GITHUB_OUTPUT
env:
OS_CLOUD: ${{ inputs.os_cloud }}
INSTANCE_NAME: ${{ inputs.instance_name }}
8 changes: 6 additions & 2 deletions .github/actions/check-volume-exists/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Check volume exists"
description: "Check volume exists"
inputs:
os_cloud:
description:
"Name of the OpenStack cloud allocation to select openstack auth settings
defined in '.config/openstack/clouds.yaml'"
required: true
volume_name:
description: "Name of the volume"
required: true
Expand All @@ -15,8 +20,6 @@ runs:
id: check_volume
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
volume=$(openstack volume list -f json | \
Expand All @@ -30,4 +33,5 @@ runs:
echo "exists [$exists]"
echo "exists=$exists" >> $GITHUB_OUTPUT
env:
OS_CLOUD: ${{ inputs.os_cloud }}
VOLUME_NAME: ${{ inputs.volume_name }}
17 changes: 10 additions & 7 deletions .github/actions/control-instance/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Control Instance"
description: "Control Instance"
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
Expand Down Expand Up @@ -53,6 +58,7 @@ runs:
id: check_instance
uses: ./.github/actions/check-instance-exists
with:
os_cloud: ${{ inputs.os_cloud }}
instance_name: ${{ steps.define.outputs.instance_name }}

- name: command results comment (Instance does not exist)
Expand All @@ -69,8 +75,6 @@ runs:
id: check_task_state
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
task_state=$(openstack server show instance-30 -f json | \
Expand All @@ -84,6 +88,7 @@ runs:
exit 1
fi
env:
OS_CLOUD: ${{ inputs.os_cloud }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}

- name: comment (server action already in progress)
Expand All @@ -104,12 +109,11 @@ runs:
if: ${{ steps.check_instance.outputs.exists == 'true' }}
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
OS_CLOUD=BIO180006_IU openstack server $COMMAND_NAME "$INSTANCE_NAME"
openstack server $COMMAND_NAME "$INSTANCE_NAME"
env:
OS_CLOUD: ${{ inputs.os_cloud }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}
COMMAND_NAME: ${{ inputs.command_name }}

Expand All @@ -130,8 +134,6 @@ runs:
if: ${{ steps.expected_status.outputs.value != '' }}
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
max_wait_time=300 # Maximum wait time in seconds (300s -> 5mins)
Expand Down Expand Up @@ -168,6 +170,7 @@ runs:
echo "status=$status" >> $GITHUB_OUTPUT
env:
OS_CLOUD: ${{ inputs.os_cloud }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}
EXPECTED_STATUS: ${{ steps.expected_status.outputs.value }}

Expand Down
8 changes: 6 additions & 2 deletions .github/actions/retrieve-metadata/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Retrieve metadata"
description: "Retrieve instance metadata"
inputs:
os_cloud:
description:
"Name of the OpenStack cloud allocation to select openstack auth settings
defined in '.config/openstack/clouds.yaml'"
required: true
instance_name:
description: "Name of the instance to retrieve metadata from"
required: true
Expand All @@ -18,8 +23,6 @@ runs:
id: instance_metadata
shell: bash
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
echo Retrieving instance "$INSTANCE_NAME" metadata
Expand Down Expand Up @@ -58,4 +61,5 @@ runs:
echo "::add-mask::$instance_pwd"
echo "instance_pwd=$instance_pwd" >> $GITHUB_OUTPUT
env:
OS_CLOUD: ${{ inputs.os_cloud }}
INSTANCE_NAME: ${{ inputs.instance_name }}
7 changes: 5 additions & 2 deletions .github/workflows/automatic-instance-shelving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
- cron: "* * * * *"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ vars.MORPHOCLOUD_OS_CLOUD }}
cancel-in-progress: true

permissions:
issues: write
contents: read
Expand All @@ -23,8 +27,6 @@ jobs:

- name: Auto Shelve
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
instance_prefix=${PREFIX:+${PREFIX}_}
Expand Down Expand Up @@ -101,6 +103,7 @@ jobs:
fi
done
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
GH_REPO: ${{ github.repository }}
PREFIX: ${{ vars.INSTANCE_NAME_PREFIX }}
7 changes: 5 additions & 2 deletions .github/workflows/collect-instance-uptime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
- cron: "* * * * *"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ vars.MORPHOCLOUD_OS_CLOUD }}
cancel-in-progress: true

jobs:
collect-instance-uptime:
runs-on: self-hosted
Expand Down Expand Up @@ -46,8 +50,6 @@ jobs:
- name: Collect Instance Uptime
id: collect-instance-uptime
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
instance_prefix=${PREFIX:+${PREFIX}_}
Expand Down Expand Up @@ -178,6 +180,7 @@ jobs:
cat $JSON_FILE
echo "--------"
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
PREFIX: ${{ vars.INSTANCE_NAME_PREFIX }}
JSON_DIR: ${{ steps.define-metadata.outputs.directory }}

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/control-instance-from-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- name: Control instance
uses: ./.github/actions/control-instance
with:
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
issue_number: ${{ inputs.issue_number }}
command_name: ${{ inputs.command_name }}
instance_name_prefix: ${{ vars.INSTANCE_NAME_PREFIX }}
11 changes: 8 additions & 3 deletions .github/workflows/control-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
reaction: "rocket"
allowed_contexts: "issue"
permissions: "read,triage,write,maintain,admin"
allowlist: "jcfr,muratmaga,${{ github.event.issue.user.login }}"
allowlist:
"${{ vars.MORPHOCLOUD_GITHUB_ADMINS }},${{
github.event.issue.user.login }}"

- name: shelve command
id: shelve_command
Expand All @@ -36,7 +38,9 @@ jobs:
reaction: "rocket"
allowed_contexts: "issue"
permissions: "read,triage,write,maintain,admin"
allowlist: "jcfr,muratmaga,${{ github.event.issue.user.login }}"
allowlist:
"${{ vars.MORPHOCLOUD_GITHUB_ADMINS }},${{
github.event.issue.user.login }}"

- name: delete command
id: delete_command
Expand All @@ -46,7 +50,7 @@ jobs:
reaction: "rocket"
allowed_contexts: "issue"
permissions: "write,maintain,admin"
allowlist: "jcfr,muratmaga"
allowlist: "${{ vars.MORPHOCLOUD_GITHUB_ADMINS }}"

- name: Set command metadata
id: command
Expand Down Expand Up @@ -88,6 +92,7 @@ jobs:
if: ${{ steps.command.outputs.continue == 'true' }}
uses: ./.github/actions/control-instance
with:
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
issue_number: ${{ github.event.issue.number }}
command_name: ${{ steps.command.outputs.command_name }}
instance_name_prefix: ${{ vars.INSTANCE_NAME_PREFIX }}
24 changes: 11 additions & 13 deletions .github/workflows/create-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
reaction: "rocket"
allowed_contexts: "issue"
permissions: "write,maintain,admin"
allowlist: "jcfr,muratmaga"
allowlist: "${{ vars.MORPHOCLOUD_GITHUB_ADMINS }}"

- uses: actions/checkout@v4

Expand Down Expand Up @@ -81,6 +81,7 @@ jobs:
id: check_instance
uses: ./.github/actions/check-instance-exists
with:
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
instance_name: ${{ steps.define.outputs.instance_name }}

- name: comment (Instance already created)
Expand All @@ -106,8 +107,6 @@ jobs:
- name: Create floating IP
id: ip_create
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
json_output=$(openstack floating ip create public -f json)
Expand All @@ -126,6 +125,8 @@ jobs:
)
echo "floating_ip_address [$floating_ip_address]"
echo "floating_ip_address=$floating_ip_address" >> $GITHUB_OUTPUT
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}

- name: comment (floating IP creation failed)
if: ${{ steps.ip_create.outcome == 'failure' && failure() }}
Expand Down Expand Up @@ -163,6 +164,7 @@ jobs:
id: check_volume
uses: ./.github/actions/check-volume-exists
with:
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
volume_name: ${{ steps.define_volume_name.outputs.volume_name }}

- name: comment (volume already exists)
Expand All @@ -181,12 +183,11 @@ jobs:
if: ${{ ! fromJSON(steps.check_volume.outputs.exists) }}
id: create_volume
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
openstack volume create --size 60 "${VOLUME_NAME}"
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
VOLUME_NAME: ${{ steps.define_volume_name.outputs.volume_name }}

- name: comment (failed to create volume)
Expand Down Expand Up @@ -217,8 +218,6 @@ jobs:
- name: Create instance
id: create_instance
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
echo Creating instance "$INSTANCE_NAME"
Expand Down Expand Up @@ -252,6 +251,7 @@ jobs:
--column status
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}
INSTANCE_FLAVOR: ${{ steps.labels.outputs.instance_flavor }}
FLOATING_IP_UUID: ${{ steps.ip_create.outputs.floating_ip_uuid }}
Expand Down Expand Up @@ -284,8 +284,6 @@ jobs:
- name: Associate floating IP with created instance
id: associated_ip
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
has_ip=$(
Expand All @@ -298,6 +296,7 @@ jobs:
openstack server add floating ip "$INSTANCE_NAME" $FLOATING_IP_ADDRESS
fi
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
FLOATING_IP_ADDRESS:
${{ steps.ip_create.outputs.floating_ip_address }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}
Expand Down Expand Up @@ -330,8 +329,6 @@ jobs:
- name: Poll instance setup status
id: instance_poll
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
echo Polling "$INSTANCE_NAME" setup status
Expand Down Expand Up @@ -366,6 +363,7 @@ jobs:
echo "status=$status" >> $GITHUB_OUTPUT
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}

- name: comment (maximum wait time exceeded)
Expand Down Expand Up @@ -396,8 +394,6 @@ jobs:
- name: Attach Volume
id: attach_volume
run: |
export OS_CLOUD=BIO180006_IU # Select openstack auth settings defined in ".config/openstack/clouds.yaml"
source ~/venv/bin/activate
instance_id=$(openstack server list -f json | \
Expand All @@ -422,6 +418,7 @@ jobs:
$instance_id \
$volume_id
env:
OS_CLOUD: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
INSTANCE_NAME: ${{ steps.define.outputs.instance_name }}
VOLUME_NAME: ${{ steps.define_volume_name.outputs.volume_name }}

Expand Down Expand Up @@ -454,6 +451,7 @@ jobs:
id: instance_metadata
uses: ./.github/actions/retrieve-metadata
with:
os_cloud: ${{ vars.MORPHOCLOUD_OS_CLOUD }}
instance_name: ${{ steps.define.outputs.instance_name }}

- name: comment (failed to retrieve instance metadata)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/request-notify-admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
from: ${{ github.event.repository.name }}
to: maga@uw.edu,jcfr@kitware.com
to: ${{ vars.MORPHOCLOUD_GITHUB_ADMIN_EMAILS }}
subject:
"[${{ github.event.repository.name }}] Approval requested for
Instance ${{ steps.define.outputs.instance_name }}"
Expand Down
Loading

0 comments on commit 55e5c0b

Please sign in to comment.