From 8ef5b25eb961e8d34b72b372e0be8acda87eba59 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Wed, 23 Oct 2024 15:50:54 -0400 Subject: [PATCH] fix: Update to MorphoCloud/MorphoCloudWorkflow@2042673 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 https://github.com/MorphoCloud/MorphoCloudWorkflow/compare/a29ea08...2042673 --- .github/ISSUE_TEMPLATE/request.yml | 15 +++- .../actions/extract-issue-fields/action.yml | 11 +++ .github/actions/send-email/action.yml | 4 +- .github/workflows/update-issue.yml | 54 +++++++++++++- .github/workflows/validate-request.yml | 72 +++++++++++++++++-- issue-commands.md | 4 +- 6 files changed, 148 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/request.yml b/.github/ISSUE_TEMPLATE/request.yml index 14805896..aa49a911 100644 --- a/.github/ISSUE_TEMPLATE/request.yml +++ b/.github/ISSUE_TEMPLATE/request.yml @@ -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 @@ -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 diff --git a/.github/actions/extract-issue-fields/action.yml b/.github/actions/extract-issue-fields/action.yml index 98610436..782e86ad 100644 --- a/.github/actions/extract-issue-fields/action.yml +++ b/.github/actions/extract-issue-fields/action.yml @@ -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: @@ -69,3 +72,11 @@ runs: sed -E 's/^<([^<>]+)>$/\1/' ) echo "email=$email" >> $GITHUB_OUTPUT + + # Also strip "<" and ">" to convert from "" to "name@domain.org" + confirm_email=$( + echo ${{ toJSON(steps.parse.outputs.data) }} | + jq -r ".confirm_email.text" | + sed -E 's/^<([^<>]+)>$/\1/' + ) + echo "confirm_email=$confirm_email" >> $GITHUB_OUTPUT diff --git a/.github/actions/send-email/action.yml b/.github/actions/send-email/action.yml index b782ba16..525c6a95 100644 --- a/.github/actions/send-email/action.yml +++ b/.github/actions/send-email/action.yml @@ -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 diff --git a/.github/workflows/update-issue.yml b/.github/workflows/update-issue.yml index f2ee3d6f..eeb2df47 100644 --- a/.github/workflows/update-issue.yml +++ b/.github/workflows/update-issue.yml @@ -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 @@ -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 \ @@ -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() }} diff --git a/.github/workflows/validate-request.yml b/.github/workflows/validate-request.yml index 649f82ee..8af7baed 100644 --- a/.github/workflows/validate-request.yml +++ b/.github/workflows/validate-request.yml @@ -4,6 +4,7 @@ on: issues: types: - opened + - edited workflow_dispatch: inputs: issue_number: @@ -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/create-or-update-comment@v4.0.0 @@ -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 }} diff --git a/issue-commands.md b/issue-commands.md index bf156be2..f2d8ba12 100644 --- a/issue-commands.md +++ b/issue-commands.md @@ -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 |