Skip to content

Commit

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

```
$ git shortlog a29ea08..2042673 --no-merges
Jean-Christophe Fillion-Robin (3):
      doc(README): Mention correct runner architecture
      feat(validate-request): Run validation when issue is edited
      feat: Update request adding "confirm email" field
```

See MorphoCloud/MorphoCloudWorkflow@a29ea08...2042673
  • Loading branch information
jcfr committed Oct 23, 2024
1 parent 0272dd1 commit 8ef5b25
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 12 deletions.
15 changes: 13 additions & 2 deletions .github/ISSUE_TEMPLATE/request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ body:
- type: input
attributes:
label: ORCID
description: Your ORCID iD profile.
description: Enter your ORCID iD for identification purposes.
placeholder: 0000-0000-0000-0000
validations:
required: true
Expand All @@ -42,6 +42,17 @@ body:
attributes:
label: Email
description:
Email to use for notifications. Please double check your entry.
Enter the email address that should receive notifications about the
instance. Ensure this is a valid, regularly checked email.
validations:
required: true

- type: input
attributes:
label: Confirm Email
description:
Re-enter your email address to verify it is correct. This step ensures
that notifications are sent to the correct address. Please double-check
for typos.
validations:
required: true
11 changes: 11 additions & 0 deletions .github/actions/extract-issue-fields/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ outputs:
email:
description: "Email"
value: ${{ steps.extract.outputs.email }}
confirm_email:
description: "Confirm Email"
value: ${{ steps.extract.outputs.confirm_email }}
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -69,3 +72,11 @@ runs:
sed -E 's/^<([^<>]+)>$/\1/'
)
echo "email=$email" >> $GITHUB_OUTPUT
# Also strip "<" and ">" to convert from "<[email protected]>" to "[email protected]"
confirm_email=$(
echo ${{ toJSON(steps.parse.outputs.data) }} |
jq -r ".confirm_email.text" |
sed -E 's/^<([^<>]+)>$/\1/'
)
echo "confirm_email=$confirm_email" >> $GITHUB_OUTPUT
4 changes: 2 additions & 2 deletions .github/actions/send-email/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ runs:
- `/shelve`: Shelve **${{ inputs.instance_name }}**
- `/unshelve`: Unshelve **${{ inputs.instance_name }}**
- `/encode_email`: Update issue description obfuscating email
- `/decode_email`: Update issue description deobfuscating email
- `/encode_email`: Update issue description obfuscating emails
- `/decode_email`: Update issue description deobfuscating emails
- `/email`: Send this email with connection URL
- name: Set error message
Expand Down
54 changes: 52 additions & 2 deletions .github/workflows/update-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,68 @@ jobs:
operation: "decode"
skip: ${{ steps.check_email_encryption.outputs.encoded == 'false' }}

- name: Check if confirm email is encoded
id: check_confirm_email_encryption
run: |
if [[ "$EMAIL" != *"@"* ]]; then
encoded="true"
else
encoded="false"
fi
echo "encoded=$encoded" >> $GITHUB_OUTPUT
env:
CONFIRM_EMAIL: ${{ steps.extract.outputs.confirm_email }}

- name: Encode confirm email
id: encode_confirm_email
if: ${{ steps.encode_email_command.outputs.continue == 'true' }}
uses: ./.github/actions/encode-decode-string
with:
input_string: ${{ steps.extract.outputs.confirm_email }}
encryption_key: ${{ secrets.STRING_ENCRYPTION_KEY }}
operation: "encode"
skip:
${{ steps.check_confirm_email_encryption.outputs.encoded == 'true'
}}

- name: Decode confirm email
id: decode_confirm_email
if: ${{ steps.decode_email_command.outputs.continue == 'true' }}
uses: ./.github/actions/encode-decode-string
with:
input_string: ${{ steps.extract.outputs.confirm_email }}
encryption_key: ${{ secrets.STRING_ENCRYPTION_KEY }}
operation: "decode"
skip:
${{ steps.check_confirm_email_encryption.outputs.encoded == 'false'
}}

- name: Set updated email
id: set_updated_email
if: ${{ steps.command.outputs.continue == 'true' }}
run: |
updated_email=""
updated_confirm_email=""
if [[ "$ENCODE_EMAIL_COMMAND_CONTINUE" == "true" ]]; then
updated_email="$ENCODED_EMAIL"
updated_confirm_email="$ENCODED_CONFIRM_EMAIL"
elif [[ "$DECODE_EMAIL_COMMAND_CONTINUE" == "true" ]]; then
updated_email="$DECODED_EMAIL"
updated_confirm_email="$DECODED_CONFIRM_EMAIL"
fi
echo "updated_email=$updated_email" >> $GITHUB_OUTPUT
echo "updated_confirm_email=$updated_confirm_email" >> $GITHUB_OUTPUT
env:
ENCODE_EMAIL_COMMAND_CONTINUE:
${{ steps.encode_email_command.outputs.continue }}
ENCODED_EMAIL: ${{ steps.encode_email.outputs.output_string }}
ENCODED_CONFIRM_EMAIL:
${{ steps.encode_confirm_email.outputs.output_string }}
DECODE_EMAIL_COMMAND_CONTINUE:
${{ steps.decode_email_command.outputs.continue }}
DECODED_EMAIL: ${{ steps.decode_email.outputs.output_string }}
DECODED_CONFIRM_EMAIL:
${{ steps.decode_confirm_email.outputs.output_string }}

- name: Update issue body
id: update_issue_body
Expand All @@ -140,8 +184,11 @@ jobs:
--json body \
--jq .body > ./body.md
# Replace email
sed "s#$OLD_EMAIL#$NEW_EMAIL#" ./body.md > ./updated_body.md
# Replace email and confirm emails
sed \
-e "s#$OLD_EMAIL#$NEW_EMAIL#" \
-e "s#$OLD_CONFIRM_EMAIL#$NEW_CONFIRM_EMAIL#" \
./body.md > ./updated_body.md
gh issue edit $ISSUE_NUMBER \
--repo $GH_REPO \
Expand All @@ -152,6 +199,9 @@ jobs:
ISSUE_NUMBER: ${{ github.event.issue.number }}
OLD_EMAIL: ${{ steps.extract.outputs.email }}
NEW_EMAIL: ${{ steps.set_updated_email.outputs.updated_email }}
OLD_CONFIRM_EMAIL: ${{ steps.extract.outputs.confirm_email }}
NEW_CONFIRM_EMAIL:
${{ steps.set_updated_email.outputs.updated_confirm_email }}

- name: command results comment (success)
if: ${{ steps.command.outputs.continue == 'true' && success() }}
Expand Down
72 changes: 68 additions & 4 deletions .github/workflows/validate-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
issues:
types:
- opened
- edited
workflow_dispatch:
inputs:
issue_number:
Expand Down Expand Up @@ -98,6 +99,60 @@ jobs:
env:
EMAIL: ${{ steps.decode_email.outputs.output_string }}

- name: Check if confirm email is encoded
id: check_confirm_email_encryption
run: |
if [[ "$EMAIL" != *"@"* ]]; then
encoded="true"
else
encoded="false"
fi
echo "encoded=$encoded" >> $GITHUB_OUTPUT
env:
CONFIRM_EMAIL: ${{ steps.extract.outputs.confirm_email }}

- name: Decode confirm email
id: decode_confirm_email
uses: ./.github/actions/encode-decode-string
with:
input_string: ${{ steps.extract.outputs.confirm_email }}
encryption_key: ${{ secrets.STRING_ENCRYPTION_KEY }}
operation: "decode"
skip:
${{ steps.check_confirm_email_encryption.outputs.encoded == 'false'
}}

- name: Check confirm email format
id: check_confirm_email_format
run: |
# Adapted from https://gist.github.com/guessi/82a73ee7eb2b1216eb9db17bb8d65dd1
email_regex="^(([A-Za-z0-9]+((\.|\-|\_|\+)?[A-Za-z0-9]?)*[A-Za-z0-9]+)|[A-Za-z0-9]+)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$"
if [[ "$CONFIRM_EMAIL" =~ $email_regex ]]; then
valid="true"
emojii="✅"
else
valid="false"
emojii="❌"
fi
echo "valid=$valid" >> $GITHUB_OUTPUT
echo "emojii=$emojii" >> $GITHUB_OUTPUT
env:
CONFIRM_EMAIL: ${{ steps.decode_confirm_email.outputs.output_string }}

- name: Check emails match
id: check_emails_match
run: |
if [[ "$EMAIL" == "$CONFIRM_EMAIL" ]]; then
valid="true"
emojii="✅"
else
valid="false"
emojii="❌"
fi
env:
EMAIL: ${{ steps.decode_email.outputs.output_string }}
CONFIRM_EMAIL: ${{ steps.decode_confirm_email.outputs.output_string }}

- name: command results comment (failure)
if: ${{ failure() }}
uses: peter-evans/[email protected]
Expand All @@ -118,9 +173,18 @@ jobs:
body: |
### Validation Results
| Check | Status |
| --------------- |:-------:|
| ORCID iD format | ${{ steps.check_orcid_format.outputs.emojii }} |
| Email format | ${{ steps.check_email_format.outputs.emojii }} |
The validation checks have completed. Below is the status of each check:
| Check | Status |
| ----------------------- |:-------:|
| ORCID iD format | ${{ steps.check_orcid_format.outputs.emojii }} |
| Email format | ${{ steps.check_email_format.outputs.emojii }} |
| Confirm Email format | ${{ steps.check_confirm_email_format.outputs.emojii }} |
| Emails match | ${{ steps.check_emails_match.outputs.emojii }} | |
> [!IMPORTANT]
> If the ORCID iD format is incorrect, edit the issue description to correct it.
>
> If either email format is invalid or the emails do not match, please update the issue description accordingly.
See details at https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
4 changes: 2 additions & 2 deletions issue-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ may be entered per comment._
| ------------------ | -------------------------------------------------- | -------------------- |
| `/shelve` | Shelve the instance. | Issue creator, Admin |
| `/unshelve` | Unshelve the instance. | Issue creator, Admin |
| `/encode_email` | Update issue description obfuscating email. | Issue creator, Admin |
| `/decode_email` | Update issue description deobfuscating email. | Issue creator, Admin |
| `/encode_email` | Update issue description obfuscating emails. | Issue creator, Admin |
| `/decode_email` | Update issue description deobfuscating emails. | Issue creator, Admin |
| `/email` | Send email to _Issue creator_ with connection URL. | Issue creator, Admin |
| `/create` | Create the instance and associated volume. | Admin |
| `/delete_instance` | Delete the instance. | Admin |
Expand Down

0 comments on commit 8ef5b25

Please sign in to comment.