Skip to content
# action.yml
name: 'Notification for Frontend Technology Change'
on:
workflow_call:
inputs:
actions:
description: 'Actions to perform'
type: string
required: true
default: '[]'
secrets:
CI_MACHINE_USER:
description: 'CI machine user'
required: true
CI_MACHINE_TOKEN:
description: 'CI machine token'
required: true
SLACK_BOT_TOKEN:
description: 'Slack bot token'
required: true
env:
GH_TOKEN: ${{ github.token }}
jobs:
resolve-data:
runs-on: ubuntu-20.04
outputs:
issue_number: ${{ steps.evaluate-actions.outputs.issue_number }}
members: ${{ steps.resolve-members.outputs.members }}
steps:
- name: Show detected actions
run: echo "${{ inputs.actions }}"
- name: Evaluate actions
id: evaluate-actions
run: |
action_json="${{ toJSON(inputs.actions) }}"
action_found=$(jq -r '.[] | select(.action == "FRONTEND_TECHNOLOGY_NOTIFY")' <<< ${action_json})
echo "action_found=[${action_found}]"
[[ -z "${action_found}" || ${action_found} == 'null' ]] && echo 'Action not found' && exit 1
issue_number=$(jq -r '.issue_number' <<< ${action_found})
echo "issue_number=[${issue_number}]"
[[ -z "${issue_number}" ]] && echo 'Issue number not found' && exit 2
echo "issue_number=${issue_number}" >> $GITHUB_OUTPUT
- name: Resolve Members
id: resolve-members
if: steps.evaluate-actions.outputs.issue_number
shell: bash
env:
UIUX_TEAM: 'ui/ux'
run: |
githack_host=raw.githack.com
githack_core_repo_url=https://${githack_host}/${{ github.repository }}
branch=/${{ github.head_ref }}
# Remove me
branch=/issue-29032-frontend-notify-when-issue-edited
github_teams_file=github-teams.json
github_teams_path=.github/data/${github_teams_file}
github_teams_url=${githack_core_repo_url}${branch}/${github_teams_path}
json=$(curl -s ${github_teams_url})
members=$(jq -r ".[] | select(.team == \"${{ env.UIUX_TEAM }}\") | .members[]" <<< "${json}")
echo "Found members: [${members}]"

Check failure on line 67 in .github/workflows/frontend-technology-notify.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/frontend-technology-notify.yml

Invalid workflow file

You have an error in your yaml syntax on line 67
declare -A deduped_array
for element in "${members[@]}"; do
deduped_array["$element"]=1
done
deduped_members=("${!deduped_array[@]}")
members=$(echo "${deduped_members[@]}")
echo "members=[${members}]"
echo "members=${members}" >> $GITHUB_OUTPUT
slack-channel-resolver:
name: Resolve Slack Channel
needs: resolve-data
if: success() && needs.resolve-data.outputs.members
uses: ./.github/workflows/slack-channel-resolver.yml
with:
github_users: ${{ needs.resolve-data.outputs.members }}
secrets:
CI_MACHINE_USER: ${{ secrets.CI_MACHINE_USER }}
CI_MACHINE_TOKEN: ${{ secrets.CI_MACHINE_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
frontend-technology-notify:
name: Notify team member ${{ matrix.members }}
needs: [resolve-data, slack-channel-resolver]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
member: ${{ fromJSON(needs.slack-channel-resolver.outputs.channel_ids) }}
env:
ISSUE_URL: https://github.com/${{ github.repository }}/issues/${{ needs.resolve-data.outputs.issue_number }}
steps:
- name: Notify member
continue-on-error: true
shell: bash
run: |
channel=${{ matrix.member }}
message="The following github issue has been marked as a Front-end issue: ${{ env.ISSUE_URL }}"
curl -X POST \
-H "Content-type: application/json" \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-d "{ \"channel\":\"${channel}\",\"text\":\"${message}\"}" \
-s \
https://slack.com/api/chat.postMessage