diff --git a/.github/actions/algolia-import-entity/action.yml b/.github/actions/algolia-import-entity/action.yml index 907d2ef27c..0134c82411 100644 --- a/.github/actions/algolia-import-entity/action.yml +++ b/.github/actions/algolia-import-entity/action.yml @@ -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 }} diff --git a/.github/actions/algolia-import-metric/action.yml b/.github/actions/algolia-import-metric/action.yml index 937737324a..c76641f032 100644 --- a/.github/actions/algolia-import-metric/action.yml +++ b/.github/actions/algolia-import-metric/action.yml @@ -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 }} diff --git a/.github/workflows/reusable-crn-algolia-sync.yml b/.github/workflows/reusable-crn-algolia-sync.yml index 2b0e4e629e..96a0a64c70 100644 --- a/.github/workflows/reusable-crn-algolia-sync.yml +++ b/.github/workflows/reusable-crn-algolia-sync.yml @@ -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 }} diff --git a/.github/workflows/reusable-crn-analytics-algolia-sync.yml b/.github/workflows/reusable-crn-analytics-algolia-sync.yml index 487d3648f5..ff360f610a 100644 --- a/.github/workflows/reusable-crn-analytics-algolia-sync.yml +++ b/.github/workflows/reusable-crn-analytics-algolia-sync.yml @@ -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 }} @@ -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: diff --git a/.github/workflows/reusable-gp2-algolia-sync.yml b/.github/workflows/reusable-gp2-algolia-sync.yml index abd1c474d3..7063a76814 100644 --- a/.github/workflows/reusable-gp2-algolia-sync.yml +++ b/.github/workflows/reusable-gp2-algolia-sync.yml @@ -100,105 +100,19 @@ 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.gp2-algolia-index }}_${{github.run_id}}_temp' - ENTITY_TYPE: ${{ (inputs.entity == 'outputs' && 'output') || (inputs.entity == 'projects' && 'project') || (inputs.entity == 'events' && 'event') || (inputs.entity == 'users' && 'user') || (inputs.entity == 'news' && 'news') || (inputs.entity == 'external-users' && 'external-user') }} - - name: Import Outputs (OUTPUTS | ALL) - if: ${{ inputs.entity == 'outputs' || inputs.entity == 'all'}} + ENTITY_TYPE: ${{ (inputs.entity == 'outputs' && 'output') || (inputs.entity == 'projects' && 'project') || (inputs.entity == 'events' && 'event') || (inputs.entity == 'users' && 'user') || (inputs.entity == 'news' && 'news') || (inputs.entity == 'external-users' && 'external-user') || (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.gp2-algolia-index }}_${{github.run_id}}_temp' app: 'gp2' - entity-type: 'output' + entity-type: ${{ (inputs.entity == 'all' && 'all') || (inputs.entity == 'outputs' && 'output') || (inputs.entity == 'projects' && 'project') || (inputs.entity == 'events' && 'event') || (inputs.entity == 'users' && 'user') || (inputs.entity == 'news' && 'news') || (inputs.entity == 'external-users' && 'external-user') || (inputs.entity == 'working-groups' && 'working-group') }} contentful-env: ${{ inputs.contentful-environment-id }} contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - - name: Import Projects (PROJECTS | ALL) - if: ${{ inputs.entity == 'projects' || 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.gp2-algolia-index }}_${{github.run_id}}_temp' - app: 'gp2' - entity-type: 'project' - contentful-env: ${{ inputs.contentful-environment-id }} - contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} - contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} - contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - - 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.gp2-algolia-index }}_${{github.run_id}}_temp' - app: 'gp2' - entity-type: 'event' - contentful-env: ${{ inputs.contentful-environment-id }} - contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} - contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} - contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - - 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.gp2-algolia-index }}_${{github.run_id}}_temp' - app: 'gp2' - entity-type: 'user' - contentful-env: ${{ inputs.contentful-environment-id }} - contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} - contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} - contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - - 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.gp2-algolia-index }}_${{github.run_id}}_temp' - app: 'gp2' - entity-type: 'news' - contentful-env: ${{ inputs.contentful-environment-id }} - contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} - contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} - contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - - name: Import External Users (EXTERNAL-USERS | ALL) - if: ${{ inputs.entity == 'external-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.gp2-algolia-index }}_${{github.run_id}}_temp' - app: 'gp2' - entity-type: 'external-user' - contentful-env: ${{ inputs.contentful-environment-id }} - contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} - contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} - contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - - name: Import Working Gropus (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.gp2-algolia-index }}_${{github.run_id}}_temp' - app: 'gp2' - entity-type: 'working-group' - contentful-env: ${{ inputs.contentful-environment-id }} - contentful-access-token: ${{ secrets.GP2_CONTENTFUL_ACCESS_TOKEN }} - contentful-management-token: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} - contentful-space-id: ${{ steps.setup.outputs.gp2-contentful-space-id }} - data-store: 'contentful' - 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: