Skip to content

Commit

Permalink
update analytics sync action & workflow (#4265)
Browse files Browse the repository at this point in the history
* update analytics sync action & workflow

* update gp2 & crn algolia entity sync

* fix script

* fix script

* convert action inputs

* fix

* remove data-store input

* rename iterator

* adding step to get entity type from input

* fix format

* Revert "adding step to get entity type from input"

This reverts commit b18684e.
  • Loading branch information
AkosuaA authored May 13, 2024
1 parent d8c3ee8 commit 0fdfa07
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 228 deletions.
14 changes: 12 additions & 2 deletions .github/actions/algolia-import-entity/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,18 @@ runs:
- name: Import Entity
shell: bash
run: |
yarn export:entity:${{ inputs.app }} $ENTITY -f $ENTITY.json
jq -c '.[]' $ENTITY.json | algolia objects import $ALGOLIA_INDEX -F -
crn_entities=(event external-author interest-group news research-output team tutorial user working-group)
gp2_entities=(event external-user news output project user working-group)
[ "${{ inputs.app }}" == "crn" ] && entities=("${crn_entities[@]}") || entities=("${gp2_entities[@]}")
if [[ "$ENTITY" == "all" ]]; then
for iteratedEntity in "${entities[@]}"; do yarn export:entity:${{ inputs.app }} $iteratedEntity -f $iteratedEntity.json
jq -c '.[]' $iteratedEntity.json | algolia objects import $ALGOLIA_INDEX -F -; done
else
yarn export:entity:${{ inputs.app }} $ENTITY -f $ENTITY.json
jq -c '.[]' $ENTITY.json | algolia objects import $ALGOLIA_INDEX -F -
fi
env:
ALGOLIA_APPLICATION_ID: ${{ inputs.algolia-app-id }}
ALGOLIA_ADMIN_API_KEY: ${{ inputs.algolia-api-key }}
Expand Down
11 changes: 9 additions & 2 deletions .github/actions/algolia-import-metric/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ runs:
- name: Import Metric
shell: bash
run: |
yarn export:analytics $METRIC -f $METRIC.json
jq -c '.[]' $METRIC.json | algolia objects import $ALGOLIA_INDEX -F -
metrics=(team-leadership team-productivity user-productivity)
if [[ "$METRIC" == "all" ]]; then
for iteratedMetric in "${metrics[@]}"; do yarn export:analytics $iteratedMetric -f $iteratedMetric.json
jq -c '.[]' $iteratedMetric.json | algolia objects import $ALGOLIA_INDEX -F -; done
else
yarn export:analytics $METRIC -f $METRIC.json
jq -c '.[]' $METRIC.json | algolia objects import $ALGOLIA_INDEX -F -
fi
env:
ALGOLIA_APPLICATION_ID: ${{ inputs.algolia-app-id }}
ALGOLIA_ADMIN_API_KEY: ${{ inputs.algolia-api-key }}
Expand Down
111 changes: 3 additions & 108 deletions .github/workflows/reusable-crn-algolia-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,120 +100,15 @@ jobs:
ALGOLIA_API_KEY: ${{ steps.algolia-keys.outputs.algolia-api-key }}
ALGOLIA_APP_ID: ${{ steps.algolia-keys.outputs.algolia-app-id }}
ALGOLIA_INDEX_TEMP: '${{ steps.setup.outputs.crn-algolia-index }}_${{ github.run_id }}_temp'
ENTITY_TYPE: ${{ (inputs.entity == 'users' && 'user') || (inputs.entity == 'research-outputs' && 'research-output') || (inputs.entity == 'external-authors' && 'external-author') || (inputs.entity == 'events' && 'event') }}
- name: Import Research Outputs (ROs | ALL)
if: ${{ inputs.entity == 'research-outputs' || inputs.entity == 'all'}}
ENTITY_TYPE: ${{ (inputs.entity == 'users' && 'user') || (inputs.entity == 'research-outputs' && 'research-output') || (inputs.entity == 'external-authors' && 'external-author') || (inputs.entity == 'events' && 'event') || (inputs.entity == 'interest-groups' && 'interest-group') || (inputs.entity == 'news' && 'news') || (inputs.entity == 'teams' && 'team') || (inputs.entity == 'tutorials' && 'tutorial') || (inputs.entity == 'working-groups' && 'working-group') }}
- name: Import Entities
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'research-output'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import Users (USERs | ALL)
if: ${{ inputs.entity == 'users' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'user'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import External Authors (EXTERNAL_AUTHORS | ALL)
if: ${{ inputs.entity == 'external-authors' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'external-author'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import Events (EVENTS | ALL)
if: ${{ inputs.entity == 'events' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'event'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import Teams (TEAMS | ALL)
if: ${{ inputs.entity == 'teams' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'team'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import WorkingGroups (WORKING_GROUPS | ALL)
if: ${{ inputs.entity == 'working-groups' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'working-group'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import InterestGroups (INTEREST_GROUPS | ALL)
if: ${{ inputs.entity == 'interest-groups' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'interest-group'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import Tutorials (TUTORIALS | ALL)
if: ${{ inputs.entity == 'tutorials' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'tutorial'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
- name: Import News (NEWS | ALL)
if: ${{ inputs.entity == 'news' || inputs.entity == 'all'}}
uses: ./.github/actions/algolia-import-entity
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-algolia-index }}_${{github.run_id}}_temp'
app: 'crn'
entity-type: 'news'
entity-type: ${{ (inputs.entity == 'all' && 'all') || (inputs.entity == 'users' && 'user') || (inputs.entity == 'research-outputs' && 'research-output') || (inputs.entity == 'external-authors' && 'external-author') || (inputs.entity == 'events' && 'event') || (inputs.entity == 'interest-groups' && 'interest-group') || (inputs.entity == 'news' && 'news') || (inputs.entity == 'teams' && 'team') || (inputs.entity == 'tutorials' && 'tutorial') || (inputs.entity == 'working-groups' && 'working-group') }}
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
Expand Down
29 changes: 2 additions & 27 deletions .github/workflows/reusable-crn-analytics-algolia-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ jobs:
ALGOLIA_APP_ID: ${{ steps.algolia-keys.outputs.algolia-app-id }}
ALGOLIA_INDEX_TEMP: '${{ steps.setup.outputs.crn-analytics-algolia-index }}_${{ github.run_id }}_temp'
ENTITY_TYPE: ${{ (inputs.metric == 'team-leadership' && 'team-leadership') || (inputs.metric == 'team-productivity' && 'team-productivity') || (inputs.metric == 'user-productivity' && 'user-productivity')}}
- name: Import team-leadership
if: ${{ inputs.metric == 'team-leadership' || inputs.metric == 'all'}}
- name: Import Metrics
uses: ./.github/actions/algolia-import-metric
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
Expand All @@ -111,31 +110,7 @@ jobs:
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
metric: 'team-leadership'
- name: Import team-productivity
if: ${{ inputs.metric == 'team-productivity' || inputs.metric == 'all'}}
uses: ./.github/actions/algolia-import-metric
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-analytics-algolia-index }}_${{github.run_id}}_temp'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
metric: 'team-productivity'
- name: Import user-productivity
if: ${{ inputs.metric == 'user-productivity' || inputs.metric == 'all'}}
uses: ./.github/actions/algolia-import-metric
with:
algolia-api-key: ${{ steps.algolia-keys.outputs.algolia-api-key }}
algolia-app-id: ${{ steps.algolia-keys.outputs.algolia-app-id }}
algolia-index: '${{ steps.setup.outputs.crn-analytics-algolia-index }}_${{github.run_id}}_temp'
contentful-env: ${{ inputs.contentful-environment-id }}
contentful-access-token: ${{ secrets.CRN_CONTENTFUL_ACCESS_TOKEN }}
contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
contentful-space-id: ${{ steps.setup.outputs.crn-contentful-space-id }}
metric: 'user-productivity'
metric: ${{ inputs.metric }}
- name: Override index with the temp one
run: yarn algolia:move-index -a $ALGOLIA_APP_ID -k $ALGOLIA_API_KEY -n $ALGOLIA_INDEX_TEMP -i $ALGOLIA_INDEX
env:
Expand Down
Loading

0 comments on commit 0fdfa07

Please sign in to comment.