Skip to content

Commit

Permalink
wip: test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed May 2, 2024
1 parent 693c870 commit 4a55b5c
Showing 1 changed file with 0 additions and 90 deletions.
90 changes: 0 additions & 90 deletions .github/workflows/create-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,96 +25,6 @@ jobs:
name: ["instance:approved"]
})
- name: Issue Forms Body Parser
id: parse
uses: zentered/[email protected]

- name: Display parsed data
run: |
echo ${{ toJSON(steps.parse.outputs.data) }} | jq .
- name: Extract fields
id: extract
run: |
email=$(
echo ${{ toJSON(steps.parse.outputs.data) }} |
jq -r ".email.text"
)
echo "email=$email" >> $GITHUB_OUTPUT
instance_flavor=$(
echo ${{ toJSON(steps.parse.outputs.data) }} |
jq -r '."instance-flavor".text | split(" - ")[0]'
)
echo "instance_flavor=$instance_flavor" >> $GITHUB_OUTPUT
- name: Create instance
id: instance_create
run: |
echo Creating instance associated with issue $NUMBER
source ~/app-cred-morpho-cloud-portal_github-runner-openrc.sh > /dev/null 2>&1
source ~/venv/bin/activate
instance_name="morpho-cloud-portal_instance-$NUMBER"
openstack server create "$instance_name" \
--nic net-id="auto_allocated_network" \
--security-group "default" \
--security-group "exosphere" \
--flavor $INSTANCE_FLAVOR \
--image "antsthings-vgl-gpu-image" \
--wait \
--column created \
--column flavor \
--column image \
--column name \
--column status
echo "instance_name=$instance_name" >> $GITHUB_OUTPUT
env:
NUMBER: ${{ github.event.issue.number }}
INSTANCE_FLAVOR: ${{ steps.extract.outputs.instance_flavor }}

- name: Create floating IP
id: ip_create
run: |
source ~/app-cred-morpho-cloud-portal_github-runner-openrc.sh > /dev/null 2>&1
source ~/venv/bin/activate
json_output=$(openstack floating ip create public -f json)
echo $json_output
floating_ip_address=$(
echo $json_output |
jq -r ".floating_ip_address"
)
echo "floating_ip_address [$floating_ip_address]"
echo "floating_ip_address=$floating_ip_address" >> $GITHUB_OUTPUT
- name: Associate floating IP with created instance
run: |
source ~/app-cred-morpho-cloud-portal_github-runner-openrc.sh > /dev/null 2>&1
source ~/venv/bin/activate
openstack server add floating ip "$INSTANCE_NAME" $IP_ADDRESS
env:
IP_ADDRESS: ${{ steps.ip_create.outputs.floating_ip_address }}
INSTANCE_NAME: ${{ steps.instance_create.outputs.instance_name }}

- name: Send mail
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde # v3.12.0
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
from: MorphoCloudPortal
to: ${{ steps.extract.outputs.email }}
subject:
"[MorphoCloudPortal] Instance ${{ github.event.issue.number }}
created"
body: Instance ${{ github.event.issue.number }} created

- name: Add "instance:created" label
if: ${{ success() }}
uses: actions/github-script@v7
Expand Down

0 comments on commit 4a55b5c

Please sign in to comment.