From a93e03c78cb5bcbdc69e48eaf457411bde785a5c Mon Sep 17 00:00:00 2001 From: R Ranathunga Date: Tue, 10 Sep 2024 14:12:24 -0700 Subject: [PATCH 01/18] chore: enable financial Risk assessments to notifiy assignees --- .../templates/assessmentAssigneeChange.ts | 9 +- .../AssessmentAssignmentTable.tsx | 123 +++++++++++------- app/schema/schema.graphql | 26 ++++ .../application_assessment_notifications.sql | 19 +++ .../application_assessment_notifications.sql | 6 + db/sqitch.plan | 1 + 6 files changed, 136 insertions(+), 48 deletions(-) create mode 100644 db/deploy/computed_columns/application_assessment_notifications.sql create mode 100644 db/revert/computed_columns/application_assessment_notifications.sql diff --git a/app/backend/lib/emails/templates/assessmentAssigneeChange.ts b/app/backend/lib/emails/templates/assessmentAssigneeChange.ts index 30e8fca4b..ba80e0778 100644 --- a/app/backend/lib/emails/templates/assessmentAssigneeChange.ts +++ b/app/backend/lib/emails/templates/assessmentAssigneeChange.ts @@ -20,6 +20,11 @@ const getCCBCUsersByIds = ` } `; +const ASSESSMENT_TYPES = { + technical: 'Technical Assessment', + financialRisk: 'Financial Risk Assessment', +}; + // Return users by their row IDs const getUsers = async (ids: number[], req: any) => { const results = await performQuery(getCCBCUsersByIds, { _rowIds: ids }, req); @@ -78,7 +83,7 @@ const assessmentAssigneeChange: EmailTemplateProvider = async ( const alerts = (assignments as Array).map((assignment) => { return { url: `${url}/analyst/application/${assignment.applicationId}/assessments/${assignment.assessmentType}`, - type: assignment.assessmentType, + type: ASSESSMENT_TYPES[assignment.assessmentType], ccbcNumber: assignment.ccbcNumber, applicationId: assignment.applicationId, }; @@ -121,7 +126,7 @@ const assessmentAssigneeChange: EmailTemplateProvider = async ( body: `{% for action in actions %} {{ action.assignors }} has assigned you the following assessment(s): {% endfor %}`, contexts, diff --git a/app/components/AnalystDashboard/AssessmentAssignmentTable.tsx b/app/components/AnalystDashboard/AssessmentAssignmentTable.tsx index c547b67ad..7c9f9e401 100644 --- a/app/components/AnalystDashboard/AssessmentAssignmentTable.tsx +++ b/app/components/AnalystDashboard/AssessmentAssignmentTable.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { graphql, useFragment } from 'react-relay'; import styled from 'styled-components'; import cookie from 'js-cookie'; @@ -148,6 +148,18 @@ const findAssessment = (assessments, assessmentType) => { }; }; +const findNotification = (notifications, notificationType) => { + const data = notifications.find( + ({ node }) => node?.notificationType === notificationType + ); + + return { + jsonData: data?.node?.jsonData, + notificationType, + createdAt: data?.node?.createdAt, + }; +}; + const StyledLink = styled.a` color: ${(props) => props.theme.color.links}; text-decoration: none; @@ -235,11 +247,7 @@ const AssessmentAssignmentTable: React.FC = ({ query }) => { } } } - notificationsByApplicationId( - orderBy: CREATED_AT_DESC - first: 1 - condition: { notificationType: "assignment_technical" } - ) { + assessmentNotifications { __id edges { node { @@ -429,9 +437,8 @@ const AssessmentAssignmentTable: React.FC = ({ query }) => { zones, allAnalysts, assessmentConnection: application.allAssessments.__id, - notifications: application.notificationsByApplicationId.edges, notificationConnectionId: - application.notificationsByApplicationId.__id, + application.assessmentNotifications?.__id, pmAssessment: findAssessment( application.allAssessments.edges, 'projectManagement' @@ -440,6 +447,10 @@ const AssessmentAssignmentTable: React.FC = ({ query }) => { application.allAssessments.edges, 'technical' ), + techNotification: findNotification( + application.assessmentNotifications.edges, + 'assignment_technical' + ), permittingAssessment: findAssessment( application.allAssessments.edges, 'permitting' @@ -456,6 +467,10 @@ const AssessmentAssignmentTable: React.FC = ({ query }) => { application.allAssessments.edges, 'financialRisk' ), + financialRiskNotification: findNotification( + application.assessmentNotifications.edges, + 'assignment_financialRisk' + ), organizationName, }; } @@ -465,46 +480,62 @@ const AssessmentAssignmentTable: React.FC = ({ query }) => { [allApplications, allAnalysts] ); - const getUserEmailByAssignedTo = (assignedTo: string) => { - const analyst = allAnalysts.edges.find( - ({ node }) => `${node.givenName} ${node.familyName}` === assignedTo - ); - return analyst ? analyst.node.email : null; - }; - - const assignments = useMemo( - () => - tableData - .filter((data: any) => { - const lastSentAt = data.notifications[0]?.node?.createdAt - ? new Date(data.notifications[0]?.node?.createdAt) - : null; - return new Date(data.techAssessment.updatedAt) >= lastSentAt; - }) - .filter( - (data: any) => - data.techAssessment.jsonData.assignedTo && - data.techAssessment.jsonData.assignedTo !== - data.notifications[0]?.node?.jsonData?.to - ) - .map((data: any) => { - return { - ccbcNumber: data.ccbcNumber, - applicationId: data.applicationId, - notificationConnectionId: data.notificationConnectionId, - updatedBy: data.techAssessment.updatedBy, - updatedAt: data.techAssessment.updatedAt, - assignedTo: data.techAssessment.jsonData?.assignedTo, - assigneeEmail: getUserEmailByAssignedTo( - data.techAssessment.jsonData?.assignedTo - ), - assessmentType: 'technical', - }; - }), - // eslint-disable-next-line react-hooks/exhaustive-deps - [tableData] + const getUserEmailByAssignedTo = useCallback( + (assignedTo: string) => { + const analyst = allAnalysts.edges.find( + ({ node }) => `${node.givenName} ${node.familyName}` === assignedTo + ); + return analyst ? analyst.node.email : null; + }, + [allAnalysts] ); + const assignments = useMemo(() => { + const createAssignment = ( + application, + assessmentKey, + assessmentType = assessmentKey + ) => { + const { updatedAt, jsonData, updatedBy } = + application[`${assessmentKey}Assessment`]; + const notification = application[`${assessmentKey}Notification`]; + const lastNotificationSentAt = notification?.createdAt + ? new Date(notification.createdAt) + : null; + + const assessmentChanged = + jsonData?.assignedTo && + jsonData.assignedTo !== notification?.jsonData?.to; + + if (new Date(updatedAt) >= lastNotificationSentAt && assessmentChanged) { + return { + ccbcNumber: application.ccbcNumber, + applicationId: application.applicationId, + notificationConnectionId: application.notificationConnectionId, + updatedBy, + updatedAt, + assignedTo: jsonData.assignedTo, + assigneeEmail: getUserEmailByAssignedTo(jsonData.assignedTo), + assessmentType, + }; + } + return null; + }; + + return tableData.reduce((assignmentsList, application) => { + const techAssignment = createAssignment(application, 'tech', 'technical'); + const financialAssignment = createAssignment( + application, + 'financialRisk' + ); + + if (techAssignment) assignmentsList.push(techAssignment); + if (financialAssignment) assignmentsList.push(financialAssignment); + + return assignmentsList; + }, []); + }, [getUserEmailByAssignedTo, tableData]); + const columns = useMemo[]>(() => { // Sonarcloud duplicate lines const sharedAssessmentCell = { diff --git a/app/schema/schema.graphql b/app/schema/schema.graphql index 18fc3720b..5da3fb06b 100644 --- a/app/schema/schema.graphql +++ b/app/schema/schema.graphql @@ -29924,6 +29924,32 @@ type Application implements Node { """Computed column that takes the slug to return an assessment form""" assessmentForm(_assessmentDataType: String!): AssessmentData + """Computed column to get assessment notifications by assessment type""" + assessmentNotifications( + """Only read the first `n` values of the set.""" + first: Int + + """Only read the last `n` values of the set.""" + last: Int + + """ + Skip the first `n` values from our `after` cursor, an alternative to cursor + based pagination. May not be used with `last`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: NotificationFilter + ): NotificationsConnection! + """Computed column to return conditional approval data""" conditionalApproval: ConditionalApprovalData diff --git a/db/deploy/computed_columns/application_assessment_notifications.sql b/db/deploy/computed_columns/application_assessment_notifications.sql new file mode 100644 index 000000000..56a705366 --- /dev/null +++ b/db/deploy/computed_columns/application_assessment_notifications.sql @@ -0,0 +1,19 @@ +-- Deploy ccbc:computed_columns/application_assessment_notifications to pg + +BEGIN; + +create or replace function ccbc_public.application_assessment_notifications(application ccbc_public.application) returns setof ccbc_public.notification as +$$ + select distinct on (notification_type) * + from ccbc_public.notification + where application_id = application_id + ORDER BY notification_type, created_at DESC; +$$ language sql stable; + +grant execute on function ccbc_public.application_assessment_notifications to ccbc_analyst; +grant execute on function ccbc_public.application_assessment_notifications to ccbc_admin; +grant execute on function ccbc_public.application_assessment_notifications to ccbc_auth_user; + +comment on function ccbc_public.application_assessment_notifications is 'Computed column to get assessment notifications by assessment type'; + +COMMIT; diff --git a/db/revert/computed_columns/application_assessment_notifications.sql b/db/revert/computed_columns/application_assessment_notifications.sql new file mode 100644 index 000000000..80100d232 --- /dev/null +++ b/db/revert/computed_columns/application_assessment_notifications.sql @@ -0,0 +1,6 @@ + +BEGIN; + +drop function ccbc_public.application_assessment_notifications; + +COMMIT; diff --git a/db/sqitch.plan b/db/sqitch.plan index a1a4a82b8..e758c8489 100644 --- a/db/sqitch.plan +++ b/db/sqitch.plan @@ -668,3 +668,4 @@ tables/communities_source_data_001_service_account 2024-08-28T16:32:48Z Rafael S @1.190.8 2024-09-04T23:08:50Z CCBC Service Account # release v1.190.8 @1.190.9 2024-09-06T20:13:21Z CCBC Service Account # release v1.190.9 @1.190.10 2024-09-10T23:10:53Z CCBC Service Account # release v1.190.10 +computed_columns/application_assessment_notifications 2024-09-06T21:58:13Z ,,, # Add notifications by assessment type field From 6bc981de253155b01501c7171fb8ed10e749ca9c Mon Sep 17 00:00:00 2001 From: R Ranathunga Date: Tue, 10 Sep 2024 14:23:28 -0700 Subject: [PATCH 02/18] refactor: assessment types --- .../templates/assesmentSecondReviewChange.ts | 15 ++------------- .../emails/templates/assessmentAssigneeChange.ts | 11 +++-------- app/data/assessmentTypes.ts | 13 +++++++++++++ .../templates/assessmentAssigneeChange.test.ts | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 app/data/assessmentTypes.ts diff --git a/app/backend/lib/emails/templates/assesmentSecondReviewChange.ts b/app/backend/lib/emails/templates/assesmentSecondReviewChange.ts index eafdf1822..9212b213b 100644 --- a/app/backend/lib/emails/templates/assesmentSecondReviewChange.ts +++ b/app/backend/lib/emails/templates/assesmentSecondReviewChange.ts @@ -1,20 +1,9 @@ +import ASSESSMENT_TYPES from '../../../../data/assessmentTypes'; import { EmailTemplate, EmailTemplateProvider, } from '../handleEmailNotification'; -const formats = { - projectManagement: { - type: 'Project Management assessment', - slug: 'project-management', - }, - permitting: { type: 'Permitting assessment', slug: 'permitting' }, - technical: { type: 'Technical assessment', slug: 'technical' }, - gis: { type: 'GIS assessment', slug: 'gis' }, - financialRisk: { type: 'Financial Risk assessment', slug: 'financial-risk' }, - screening: { type: 'Eligibility Screening', slug: 'screening' }, -}; - const assesmentSecondReviewChange: EmailTemplateProvider = ( applicationId: string, url: string, @@ -22,7 +11,7 @@ const assesmentSecondReviewChange: EmailTemplateProvider = ( params: any ): EmailTemplate => { const { ccbcNumber, assessmentType } = params; - const { type, slug } = formats[assessmentType]; + const { type, slug } = ASSESSMENT_TYPES[assessmentType]; return { emailTo: [34, 71], // Temporary IDs to handle email recipients diff --git a/app/backend/lib/emails/templates/assessmentAssigneeChange.ts b/app/backend/lib/emails/templates/assessmentAssigneeChange.ts index ba80e0778..1587ebf49 100644 --- a/app/backend/lib/emails/templates/assessmentAssigneeChange.ts +++ b/app/backend/lib/emails/templates/assessmentAssigneeChange.ts @@ -1,5 +1,5 @@ import { Context } from 'backend/lib/ches/sendEmailMerge'; - +import ASSESSMENT_TYPES from '../../../../data/assessmentTypes'; import { EmailTemplate, EmailTemplateProvider, @@ -20,11 +20,6 @@ const getCCBCUsersByIds = ` } `; -const ASSESSMENT_TYPES = { - technical: 'Technical Assessment', - financialRisk: 'Financial Risk Assessment', -}; - // Return users by their row IDs const getUsers = async (ids: number[], req: any) => { const results = await performQuery(getCCBCUsersByIds, { _rowIds: ids }, req); @@ -82,8 +77,8 @@ const assessmentAssigneeChange: EmailTemplateProvider = async ( ([assignor, assignments]) => { const alerts = (assignments as Array).map((assignment) => { return { - url: `${url}/analyst/application/${assignment.applicationId}/assessments/${assignment.assessmentType}`, - type: ASSESSMENT_TYPES[assignment.assessmentType], + url: `${url}/analyst/application/${assignment.applicationId}/assessments/${ASSESSMENT_TYPES[assignment.assessmentType].slug}`, + type: ASSESSMENT_TYPES[assignment.assessmentType].type, ccbcNumber: assignment.ccbcNumber, applicationId: assignment.applicationId, }; diff --git a/app/data/assessmentTypes.ts b/app/data/assessmentTypes.ts new file mode 100644 index 000000000..05d9a5c92 --- /dev/null +++ b/app/data/assessmentTypes.ts @@ -0,0 +1,13 @@ +const ASSESSMENT_TYPES = { + projectManagement: { + type: 'Project Management assessment', + slug: 'project-management', + }, + permitting: { type: 'Permitting assessment', slug: 'permitting' }, + technical: { type: 'Technical assessment', slug: 'technical' }, + gis: { type: 'GIS assessment', slug: 'gis' }, + financialRisk: { type: 'Financial Risk assessment', slug: 'financial-risk' }, + screening: { type: 'Eligibility Screening', slug: 'screening' }, +}; + +export default ASSESSMENT_TYPES; diff --git a/app/tests/backend/lib/emails/templates/assessmentAssigneeChange.test.ts b/app/tests/backend/lib/emails/templates/assessmentAssigneeChange.test.ts index 7a3c17c82..bfa361db3 100644 --- a/app/tests/backend/lib/emails/templates/assessmentAssigneeChange.test.ts +++ b/app/tests/backend/lib/emails/templates/assessmentAssigneeChange.test.ts @@ -58,7 +58,7 @@ describe('assessmentAssigneeChange template', () => { }, { applicationId: 3, - assessmentType: 'technical', + assessmentType: 'financialRisk', assignedTo: 'Tester 2', assigneeEmail: 'tester2@mail.com', ccbcNumber: 'CCBC-000003', @@ -93,7 +93,7 @@ describe('assessmentAssigneeChange template', () => { { ccbcNumber: 'CCBC-000001', applicationId: 1, - type: 'technical', + type: 'Technical assessment', url: 'http://mock_host.ca/analyst/application/1/assessments/technical', }, ], @@ -106,7 +106,7 @@ describe('assessmentAssigneeChange template', () => { { ccbcNumber: 'CCBC-000002', applicationId: 2, - type: 'technical', + type: 'Technical assessment', url: 'http://mock_host.ca/analyst/application/2/assessments/technical', }, ], @@ -117,8 +117,8 @@ describe('assessmentAssigneeChange template', () => { { ccbcNumber: 'CCBC-000003', applicationId: 3, - type: 'technical', - url: 'http://mock_host.ca/analyst/application/3/assessments/technical', + type: 'Financial Risk assessment', + url: 'http://mock_host.ca/analyst/application/3/assessments/financial-risk', }, ], assignors: 'Assignor 3', From a760e6d0a9d2510a1cbf07e5e2ac4c3b3dd8a151 Mon Sep 17 00:00:00 2001 From: R Ranathunga Date: Wed, 11 Sep 2024 09:53:09 -0700 Subject: [PATCH 03/18] fix: remove unwanted status text from RFI --- app/components/Form/GenericFormStatus.tsx | 12 ++++++++---- app/components/Form/RfiFormStatus.tsx | 1 + .../[applicationId]/rfi/[rfiId]/upload.test.tsx | 2 +- .../form/[id]/rfi/[applicantRfiId].test.tsx | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/components/Form/GenericFormStatus.tsx b/app/components/Form/GenericFormStatus.tsx index 201390b34..c136384b2 100644 --- a/app/components/Form/GenericFormStatus.tsx +++ b/app/components/Form/GenericFormStatus.tsx @@ -44,6 +44,7 @@ interface Props { error?: JSX.Element; projectName: string; status: string; + showProjectDetails?: boolean; } const GenericFormStatus: React.FC = ({ @@ -52,6 +53,7 @@ const GenericFormStatus: React.FC = ({ error, projectName, status, + showProjectDetails = true, }) => { let savingStatusIndicator = ( <> @@ -76,10 +78,12 @@ const GenericFormStatus: React.FC = ({ return ( - - {status} - {projectName} - + {showProjectDetails && ( + + {status} + {projectName} + + )} {savingStatusIndicator} diff --git a/app/components/Form/RfiFormStatus.tsx b/app/components/Form/RfiFormStatus.tsx index a77951e83..0447eef6c 100644 --- a/app/components/Form/RfiFormStatus.tsx +++ b/app/components/Form/RfiFormStatus.tsx @@ -33,6 +33,7 @@ const RfiFormStatus: React.FC = ({ application, isSaving, error }) => { status={status} updatedAt={updatedAt} error={error} + showProjectDetails={false} /> ); }; diff --git a/app/tests/pages/analyst/application/[applicationId]/rfi/[rfiId]/upload.test.tsx b/app/tests/pages/analyst/application/[applicationId]/rfi/[rfiId]/upload.test.tsx index e681ddfe2..6fb055469 100644 --- a/app/tests/pages/analyst/application/[applicationId]/rfi/[rfiId]/upload.test.tsx +++ b/app/tests/pages/analyst/application/[applicationId]/rfi/[rfiId]/upload.test.tsx @@ -54,7 +54,7 @@ describe('The applicantRfiId Page', () => { pageTestingHelper.loadQuery(); pageTestingHelper.renderPage(); - expect(screen.getAllByText('projName')[1]).toBeInTheDocument(); + expect(screen.getByText(/Last saved: Dec 1/)).toBeInTheDocument(); }); it('displays the due by date', () => { diff --git a/app/tests/pages/applicantportal/form/[id]/rfi/[applicantRfiId].test.tsx b/app/tests/pages/applicantportal/form/[id]/rfi/[applicantRfiId].test.tsx index a3b54155d..7e888a795 100644 --- a/app/tests/pages/applicantportal/form/[id]/rfi/[applicantRfiId].test.tsx +++ b/app/tests/pages/applicantportal/form/[id]/rfi/[applicantRfiId].test.tsx @@ -72,7 +72,7 @@ describe('The applicantRfiId Page', () => { pageTestingHelper.loadQuery(); pageTestingHelper.renderPage(); - expect(screen.getByText('projName')).toBeInTheDocument(); + expect(screen.getByText(/Last saved: Dec 1/)).toBeInTheDocument(); }); it('displays the due by date', () => { From afc5cdeb2037f8c9cca08df7524b5c935ae9404c Mon Sep 17 00:00:00 2001 From: CCBC Service Account <116113628+ccbc-service-account@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:13:44 +0000 Subject: [PATCH 04/18] chore: release v1.190.11 --- CHANGELOG.md | 2 ++ db/sqitch.plan | 1 + package.json | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc5b3e19..4770ab0d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## [1.190.11](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.190.10...v1.190.11) (2024-09-12) + ## [1.190.10](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.190.9...v1.190.10) (2024-09-10) ## [1.190.9](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.190.8...v1.190.9) (2024-09-06) diff --git a/db/sqitch.plan b/db/sqitch.plan index e758c8489..62af336e7 100644 --- a/db/sqitch.plan +++ b/db/sqitch.plan @@ -669,3 +669,4 @@ tables/communities_source_data_001_service_account 2024-08-28T16:32:48Z Rafael S @1.190.9 2024-09-06T20:13:21Z CCBC Service Account # release v1.190.9 @1.190.10 2024-09-10T23:10:53Z CCBC Service Account # release v1.190.10 computed_columns/application_assessment_notifications 2024-09-06T21:58:13Z ,,, # Add notifications by assessment type field +@1.190.11 2024-09-12T18:13:42Z CCBC Service Account # release v1.190.11 diff --git a/package.json b/package.json index d11ff1205..eae6c03d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CONN-CCBC-portal", - "version": "1.190.10", + "version": "1.190.11", "main": "index.js", "repository": "https://github.com/bcgov/CONN-CCBC-portal.git", "author": "Romer, Meherzad CITZ:EX ", From 8aab0174bd8cd331e003b2a4dd43c985f5bdcd11 Mon Sep 17 00:00:00 2001 From: CCBC Service Account <116113628+ccbc-service-account@users.noreply.github.com> Date: Thu, 12 Sep 2024 20:48:13 +0000 Subject: [PATCH 05/18] chore: release v1.190.12 --- CHANGELOG.md | 6 ++++++ db/sqitch.plan | 1 + package.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4770ab0d2..9d645df35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [1.190.12](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.190.11...v1.190.12) (2024-09-12) + +### Bug Fixes + +- remove unwanted status text from RFI ([a760e6d](https://github.com/bcgov/CONN-CCBC-portal/commit/a760e6d0a9d2510a1cbf07e5e2ac4c3b3dd8a151)) + ## [1.190.11](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.190.10...v1.190.11) (2024-09-12) ## [1.190.10](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.190.9...v1.190.10) (2024-09-10) diff --git a/db/sqitch.plan b/db/sqitch.plan index 62af336e7..4765e01ff 100644 --- a/db/sqitch.plan +++ b/db/sqitch.plan @@ -670,3 +670,4 @@ tables/communities_source_data_001_service_account 2024-08-28T16:32:48Z Rafael S @1.190.10 2024-09-10T23:10:53Z CCBC Service Account # release v1.190.10 computed_columns/application_assessment_notifications 2024-09-06T21:58:13Z ,,, # Add notifications by assessment type field @1.190.11 2024-09-12T18:13:42Z CCBC Service Account # release v1.190.11 +@1.190.12 2024-09-12T20:48:11Z CCBC Service Account # release v1.190.12 diff --git a/package.json b/package.json index eae6c03d5..01d1e8ad1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CONN-CCBC-portal", - "version": "1.190.11", + "version": "1.190.12", "main": "index.js", "repository": "https://github.com/bcgov/CONN-CCBC-portal.git", "author": "Romer, Meherzad CITZ:EX ", From 13a32b24532a66881246482888505c40e28b53ac Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Fri, 6 Sep 2024 16:20:41 -0400 Subject: [PATCH 06/18] feat(ci): sneaky change to change rebase condition --- .github/pull_request_template.md | 2 ++ .github/workflows/main.yaml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c96ff6021..1a29eb5e7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,3 +10,5 @@ Add detailed description of the changes if the PR title isn't enough --> - [ ] Check to trigger automatic release process + +- [ ] Check for automatic rebasing diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 892501e54..215f818e7 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -79,6 +79,7 @@ jobs: const { owner, repo } = context.repo const listOfBranches = []; const prs = await github.rest.pulls.list({ owner, repo, state: 'open' }); + const checkboxText = "[x] Check for automatic rebasing"; for (const pr of prs.data) { // check if PR is rebaseable, not draft, and mergable before adding to list const baseBranch = pr.base.ref; @@ -91,7 +92,8 @@ jobs: head: headBranch }); - if(comparison.data.behind_by > 0 && !pr.draft && pr.requested_reviewers.length > 0){ + const checkboxChecked = pr.body.includes(checkboxText); + if(comparison.data.behind_by > 0 && !pr.draft && checkboxChecked){ listOfBranches.push(pr.head.ref); } } From cc2f4567802a6c21e17bb60e0207e0c5eeb1d27e Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Fri, 6 Sep 2024 17:07:11 -0400 Subject: [PATCH 07/18] feat(ci): move to merge conflict column if in PO review --- .github/workflows/move-to-merge-conflict.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/move-to-merge-conflict.yaml diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml new file mode 100644 index 000000000..5eebcaf5c --- /dev/null +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -0,0 +1,60 @@ +name: Move Ticket to Merge Conflict Column + +on: + pull_request_target: + types: [edited, synchronize] + workflow_call: + secrets: + JIRA_AUTH: { required: true } + +jobs: + move-to-merge-conflict: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Get JIRA Issue Key + id: extract_jira_key + run: | + echo "JIRA_KEY=$(echo "$FEATURE_NAME" | grep -oE 'NDT-[0-9]+')" >> $GITHUB_ENV + - name: Check Status of issue + id: get_status + run: | + response=$(curl -s -X GET \ + -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ + -H "Content-Type: application/json" \ + "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") + + status=$(echo "$response" | jq -r '.fields.status.name') + echo "Issue status: $status" + + echo "::set-output name=status::$status" + - name: Does PR have conflic + id: check_conflict + run: | + git config user.name "CCBC Service Account" + git config user.email "116113628+ccbc-service-account@users.noreply.github.com" + git fetch origin + git checkout main + git pull origin main + git checkout ${{ github.event.pull_request.head.ref }} + git pull origin ${{ github.event.pull_request.head.ref }} + set -e + git merge main --no-commit --no-ff + MERGE_STATUS=$? + echo $MERGE_STATUS + echo "MERGE_STATUS=$MERGE_STATUS" >> $GITHUB_ENV + - name: Move to Merge Conflict Column + # if: steps.check_conflict.outputs.MERGE_STATUS != 0 && steps.get_status.outputs.status == 'PO REVIEW' + # for testing + if: steps.check_conflict.outputs.MERGE_STATUS != 0 && steps.get_status.outputs.status == 'IN PROGRESS (DRAFT PR)' + run: | + curl -X POST \ + -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ + -H "Content-Type: application/json" \ + -d '{ + "transition": { + "id": "9" + } + }' \ + "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY/transitions" From ba0403ec45ddd3fa66751daf944cd7efb5a2dcbc Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 09:55:06 -0400 Subject: [PATCH 08/18] chore: test with fake merge conflict --- .github/workflows/move-to-merge-conflict.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index 5eebcaf5c..7629c0f4f 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -1,7 +1,8 @@ name: Move Ticket to Merge Conflict Column on: - pull_request_target: + pull_request: + # pull_request_target: types: [edited, synchronize] workflow_call: secrets: @@ -13,6 +14,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + persist-credentials: false - name: Get JIRA Issue Key id: extract_jira_key run: | @@ -43,7 +46,7 @@ jobs: git merge main --no-commit --no-ff MERGE_STATUS=$? echo $MERGE_STATUS - echo "MERGE_STATUS=$MERGE_STATUS" >> $GITHUB_ENV + echo "MERGE_STATUS=1" >> $GITHUB_ENV - name: Move to Merge Conflict Column # if: steps.check_conflict.outputs.MERGE_STATUS != 0 && steps.get_status.outputs.status == 'PO REVIEW' # for testing From fac3e2f6424cbb4b87e9f380ff0e3b64bfb2160c Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 09:58:58 -0400 Subject: [PATCH 09/18] chore: fix using github output --- .github/workflows/move-to-merge-conflict.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index 7629c0f4f..5bcfa905d 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -46,7 +46,7 @@ jobs: git merge main --no-commit --no-ff MERGE_STATUS=$? echo $MERGE_STATUS - echo "MERGE_STATUS=1" >> $GITHUB_ENV + echo "MERGE_STATUS=1" >> $GITHUB_OUTPUT - name: Move to Merge Conflict Column # if: steps.check_conflict.outputs.MERGE_STATUS != 0 && steps.get_status.outputs.status == 'PO REVIEW' # for testing From 1c4eda1e74295c14e8a1d54fa901e5230649c629 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 10:04:46 -0400 Subject: [PATCH 10/18] chore: define outputs --- .github/workflows/move-to-merge-conflict.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index 5bcfa905d..d11902d0f 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -10,6 +10,9 @@ on: jobs: move-to-merge-conflict: + outputs: + MERGE_STATUS: ${{ steps.check_conflict.outputs.MERGE_STATUS }} + status: ${{ steps.get_status.outputs.status }} runs-on: ubuntu-latest steps: - name: Checkout code @@ -27,7 +30,7 @@ jobs: -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ -H "Content-Type: application/json" \ "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") - + echo "$response" status=$(echo "$response" | jq -r '.fields.status.name') echo "Issue status: $status" From d649f31ad9706444fc3ccde026c5b1506408a3af Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 10:06:30 -0400 Subject: [PATCH 11/18] chore: see if JIRA key and response are being generated --- .github/workflows/move-to-merge-conflict.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index d11902d0f..7f0c6a1e6 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -30,7 +30,8 @@ jobs: -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ -H "Content-Type: application/json" \ "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") - echo "$response" + echo "Jira Key: $JIRA_KEY" + echo "Response: $response" status=$(echo "$response" | jq -r '.fields.status.name') echo "Issue status: $status" From 35b5e12ab788ef8f4d040f4e4221359e799c1bde Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 10:08:31 -0400 Subject: [PATCH 12/18] chore: add missing env FEATURE_NAME --- .github/workflows/move-to-merge-conflict.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index 7f0c6a1e6..81a0a7d9b 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -7,6 +7,8 @@ on: workflow_call: secrets: JIRA_AUTH: { required: true } +env: + FEATURE_NAME: ${{ github.head_ref }} jobs: move-to-merge-conflict: From 731708cc87c99384185c0c248cd30f34fd6aa844 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 11:00:53 -0400 Subject: [PATCH 13/18] chore: check secrets passing --- .github/workflows/move-to-merge-conflict.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index 81a0a7d9b..c822e2381 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -32,6 +32,9 @@ jobs: -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ -H "Content-Type: application/json" \ "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") + if [[ -z "${{ secrets.JIRA_AUTH }}" ]]; then + echo "secrets.JIRA_AUTH is empty" + fi echo "Jira Key: $JIRA_KEY" echo "Response: $response" status=$(echo "$response" | jq -r '.fields.status.name') From 60884fc105b7b4889313294b7bbd43eccfe36f46 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 11:03:36 -0400 Subject: [PATCH 14/18] chore: try with passing as env --- .github/workflows/move-to-merge-conflict.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index c822e2381..ae5e5f258 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -26,13 +26,15 @@ jobs: run: | echo "JIRA_KEY=$(echo "$FEATURE_NAME" | grep -oE 'NDT-[0-9]+')" >> $GITHUB_ENV - name: Check Status of issue + env: + JIRA_AUTH: ${{ secrets.JIRA_AUTH }} id: get_status run: | response=$(curl -s -X GET \ -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ -H "Content-Type: application/json" \ "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") - if [[ -z "${{ secrets.JIRA_AUTH }}" ]]; then + if [[ -z "$JIRA_AUTH" ]]; then echo "secrets.JIRA_AUTH is empty" fi echo "Jira Key: $JIRA_KEY" From 78eda42954f4db7ba4630bb4e5d33d835583809e Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 11:24:17 -0400 Subject: [PATCH 15/18] chore: use development environment to access secret key maybe --- .github/workflows/move-to-merge-conflict.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml index ae5e5f258..aca8d2e99 100644 --- a/.github/workflows/move-to-merge-conflict.yaml +++ b/.github/workflows/move-to-merge-conflict.yaml @@ -12,6 +12,8 @@ env: jobs: move-to-merge-conflict: + environment: + name: development outputs: MERGE_STATUS: ${{ steps.check_conflict.outputs.MERGE_STATUS }} status: ${{ steps.get_status.outputs.status }} @@ -26,17 +28,12 @@ jobs: run: | echo "JIRA_KEY=$(echo "$FEATURE_NAME" | grep -oE 'NDT-[0-9]+')" >> $GITHUB_ENV - name: Check Status of issue - env: - JIRA_AUTH: ${{ secrets.JIRA_AUTH }} id: get_status run: | response=$(curl -s -X GET \ -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ -H "Content-Type: application/json" \ "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") - if [[ -z "$JIRA_AUTH" ]]; then - echo "secrets.JIRA_AUTH is empty" - fi echo "Jira Key: $JIRA_KEY" echo "Response: $response" status=$(echo "$response" | jq -r '.fields.status.name') From fa2194cb3011a91c231b8dba5e52be7f6a07d9b7 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 17:16:55 -0400 Subject: [PATCH 16/18] refactor: change to use pull_request_target and workflow_run --- .github/workflows/detect-conflict.yaml | 42 ++++++++++ .github/workflows/move-on-merge-conlifct.yaml | 82 +++++++++++++++++++ .github/workflows/move-to-merge-conflict.yaml | 71 ---------------- 3 files changed, 124 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/detect-conflict.yaml create mode 100644 .github/workflows/move-on-merge-conlifct.yaml delete mode 100644 .github/workflows/move-to-merge-conflict.yaml diff --git a/.github/workflows/detect-conflict.yaml b/.github/workflows/detect-conflict.yaml new file mode 100644 index 000000000..0a5685784 --- /dev/null +++ b/.github/workflows/detect-conflict.yaml @@ -0,0 +1,42 @@ +name: Detect Merge Conflict + +on: + pull_request_target: + types: [edited, synchronize] + +jobs: + move-to-merge-conflict: + environment: + name: development + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Does PR have conflic + id: check_conflict + run: | + git config user.name "CCBC Service Account" + git config user.email "116113628+ccbc-service-account@users.noreply.github.com" + git fetch origin + git checkout main + git pull origin main + git checkout ${{ github.event.pull_request.head.ref }} + git pull origin ${{ github.event.pull_request.head.ref }} + set -e + git merge main --no-commit --no-ff + MERGE_STATUS=$? + echo $MERGE_STATUS + echo "MERGE_STATUS=$MERGE_STATUS" >> $GITHUB_OUTPUT + - name: Save PR number + if: steps.check_conflict.outputs.MERGE_STATUS != 0 + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + mkdir -p ./pr + echo $PR_NUMBER > ./pr/pr_number + - uses: actions/upload-artifact@v4 + with: + name: pr_number + path: pr/ diff --git a/.github/workflows/move-on-merge-conlifct.yaml b/.github/workflows/move-on-merge-conlifct.yaml new file mode 100644 index 000000000..ce3e83bbe --- /dev/null +++ b/.github/workflows/move-on-merge-conlifct.yaml @@ -0,0 +1,82 @@ +name: Move Merge Conflict Tickets + +on: + workflow_run: + workflows: ['Detect Merge Conflict'] + types: + - completed + +jobs: + get-feature-name: + environment: + name: development + runs-on: ubuntu-latest + steps: + - name: Download Artifact + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo + const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner, + repo, + run_id: context.payload.workflow_run.id + }) + const matchArtifact = allArtifacts.data.find(artifact => artifact.name === 'feature-name')[0] + const download = await github.rest.actions.downloadArtifact({ + owner, + repo, + artifact_id: matchArtifact.id, + archive_format: 'zip' + }) + const fs = require('fs') + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)) + - run: unzip pr_number.zip + - name: Check PR details and get feature name + id: get_feature_name + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + const fs = require('fs') + const prNumber = Number(fs.readFileSync('pr/pr_number')) + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }) + if (pr.head.repo.fork){ + return + } + const featureName = pr.head.ref + const regex = /NDT-\d+/g; + const match = featureName.match(regex) + return match + - name: Check Status of issue + if: startsWith(steps.get_feature_name.outputs.result, 'NDT-') + id: get_status + run: | + response=$(curl -s -X GET \ + -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ + -H "Content-Type: application/json" \ + "https://connectivitydivision.atlassian.net/rest/api/3/issue/${{ steps.get_feature_name.outputs.result }}") + echo "Jira Key: $JIRA_KEY" + echo "Response: $response" + status=$(echo "$response" | jq -r '.fields.status.name') + echo "Issue status: $status" + + echo "::set-output name=status::$status" + - name: Move to Merge Conflict Column + if: steps.get_status.outputs.status == 'PO REVIEW' + run: | + curl -X POST \ + -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ + -H "Content-Type: application/json" \ + -d '{ + "transition": { + "id": "9" + } + }' \ + "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY/transitions" diff --git a/.github/workflows/move-to-merge-conflict.yaml b/.github/workflows/move-to-merge-conflict.yaml deleted file mode 100644 index aca8d2e99..000000000 --- a/.github/workflows/move-to-merge-conflict.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: Move Ticket to Merge Conflict Column - -on: - pull_request: - # pull_request_target: - types: [edited, synchronize] - workflow_call: - secrets: - JIRA_AUTH: { required: true } -env: - FEATURE_NAME: ${{ github.head_ref }} - -jobs: - move-to-merge-conflict: - environment: - name: development - outputs: - MERGE_STATUS: ${{ steps.check_conflict.outputs.MERGE_STATUS }} - status: ${{ steps.get_status.outputs.status }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Get JIRA Issue Key - id: extract_jira_key - run: | - echo "JIRA_KEY=$(echo "$FEATURE_NAME" | grep -oE 'NDT-[0-9]+')" >> $GITHUB_ENV - - name: Check Status of issue - id: get_status - run: | - response=$(curl -s -X GET \ - -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ - -H "Content-Type: application/json" \ - "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY") - echo "Jira Key: $JIRA_KEY" - echo "Response: $response" - status=$(echo "$response" | jq -r '.fields.status.name') - echo "Issue status: $status" - - echo "::set-output name=status::$status" - - name: Does PR have conflic - id: check_conflict - run: | - git config user.name "CCBC Service Account" - git config user.email "116113628+ccbc-service-account@users.noreply.github.com" - git fetch origin - git checkout main - git pull origin main - git checkout ${{ github.event.pull_request.head.ref }} - git pull origin ${{ github.event.pull_request.head.ref }} - set -e - git merge main --no-commit --no-ff - MERGE_STATUS=$? - echo $MERGE_STATUS - echo "MERGE_STATUS=1" >> $GITHUB_OUTPUT - - name: Move to Merge Conflict Column - # if: steps.check_conflict.outputs.MERGE_STATUS != 0 && steps.get_status.outputs.status == 'PO REVIEW' - # for testing - if: steps.check_conflict.outputs.MERGE_STATUS != 0 && steps.get_status.outputs.status == 'IN PROGRESS (DRAFT PR)' - run: | - curl -X POST \ - -H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \ - -H "Content-Type: application/json" \ - -d '{ - "transition": { - "id": "9" - } - }' \ - "https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY/transitions" From c28496efadd0069ad122eb2bc8534335ed0748a5 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 17:21:23 -0400 Subject: [PATCH 17/18] chore: use filter rather than find --- .github/workflows/move-on-merge-conlifct.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/move-on-merge-conlifct.yaml b/.github/workflows/move-on-merge-conlifct.yaml index ce3e83bbe..58a6a6762 100644 --- a/.github/workflows/move-on-merge-conlifct.yaml +++ b/.github/workflows/move-on-merge-conlifct.yaml @@ -23,7 +23,7 @@ jobs: repo, run_id: context.payload.workflow_run.id }) - const matchArtifact = allArtifacts.data.find(artifact => artifact.name === 'feature-name')[0] + const matchArtifact = allArtifacts.data.filter(artifact => artifact.name === 'feature-name')[0] const download = await github.rest.actions.downloadArtifact({ owner, repo, From a66e92087e04b12fc92ce7ce59d661a2317cf149 Mon Sep 17 00:00:00 2001 From: Anthony Bushara Date: Mon, 9 Sep 2024 17:28:27 -0400 Subject: [PATCH 18/18] chore: fix potential expression injection --- .github/workflows/detect-conflict.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detect-conflict.yaml b/.github/workflows/detect-conflict.yaml index 0a5685784..fdc59728a 100644 --- a/.github/workflows/detect-conflict.yaml +++ b/.github/workflows/detect-conflict.yaml @@ -15,6 +15,8 @@ jobs: with: persist-credentials: false - name: Does PR have conflic + env: + HEAD_REF: ${{ github.event.pull_request.head.ref }} id: check_conflict run: | git config user.name "CCBC Service Account" @@ -22,8 +24,8 @@ jobs: git fetch origin git checkout main git pull origin main - git checkout ${{ github.event.pull_request.head.ref }} - git pull origin ${{ github.event.pull_request.head.ref }} + git checkout "$HEAD_REF" + git pull origin "$HEAD_REF" set -e git merge main --no-commit --no-ff MERGE_STATUS=$?