diff --git a/.github/workflows/pr_title_check.yml b/.github/workflows/pr_title_check.yml index 0a99a40..bb79a99 100644 --- a/.github/workflows/pr_title_check.yml +++ b/.github/workflows/pr_title_check.yml @@ -1,42 +1,27 @@ name: PR Title Check on: - # Will be null if PR title was not updated workflow_call: - inputs: - PR_TITLE: - required: true - type: string jobs: pr_title_format_check: runs-on: ubuntu-latest steps: - - name: Set Up-to-date PR Title - run: | - if [[ "${{ inputs.PR_TITLE }}" ]]; then - echo "PR title was updated by dependabot prefixer." - echo "PR_TITLE=${{ inputs.PR_TITLE }}" >> $GITHUB_ENV - else - echo "PR title was not updated by dependabot prefixer." - echo "PR_TITLE=${{ github.event.pull_request.title }}" >> $GITHUB_ENV - fi - - name: Check PR Title is Prefixed with Change Type run: | - if [[ "${{ env.PR_TITLE }}" =~ ^(Fix|Update|New|Breaking|Docs|Build|Upgrade|Chore):.*$ ]]; then + if [[ "${{ github.event.pull_request.title }}" =~ ^(Fix|Update|New|Breaking|Docs|Build|Upgrade|Chore):.*$ ]]; then echo "PR title is prefixed with change type." else echo "PR title is not prefixed with change type." echo "Please prefix your PR title with a change type (Fix, Update, New, Breaking, Docs, Build, Upgrade, Chore)." - echo "See the ESLint commit convention for more details:" - echo "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint" + echo "See the contributing guide for more details:" + echo "https://github.com/NHSDigital/nhs-fhir-middy-error-handler/blob/main/CONTRIBUTING.md" exit 1 fi - name: Check PR Title contains Ticket/Dependabot Reference run: | - if [[ "${{ env.PR_TITLE }}" =~ ^.*:.*\[(AEA-[0-9]{1,4}|dependabot)\].*-.*$ ]]; then + if [[ "${{ github.event.pull_request.title }}" =~ ^.*:.*\[([A-Z]+-[0-9]+|dependabot)\].*-.*$ ]]; then echo "PR title contains ticket or dependabot reference." else echo "PR title does not contain ticket or dependabot reference." diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 3fc5f1b..7a8861f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -5,11 +5,7 @@ on: branches: [main] jobs: - dependabot_prefix_title: - uses: ./.github/workflows/rename_dependabot_prs.yml - quality_checks: - needs: dependabot_prefix_title uses: ./.github/workflows/quality_checks.yml with: BRANCH_NAME: ${{ github.event.pull_request.head.ref }} @@ -17,8 +13,4 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} pr_title_format_check: - needs: dependabot_prefix_title uses: ./.github/workflows/pr_title_check.yml - with: - # Will be null if PR title was not updated - PR_TITLE: ${{ needs.dependabot_prefix_title.outputs.updated_pr_title }} diff --git a/.github/workflows/quality_checks.yml b/.github/workflows/quality_checks.yml index 6f5e453..50f5b64 100644 --- a/.github/workflows/quality_checks.yml +++ b/.github/workflows/quality_checks.yml @@ -11,7 +11,7 @@ on: required: true jobs: - quality_checks: + lint_build_test: runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/rename_dependabot_prs.yml b/.github/workflows/rename_dependabot_prs.yml deleted file mode 100644 index 3dc310d..0000000 --- a/.github/workflows/rename_dependabot_prs.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Dependabot Prefix PR Title - -on: - workflow_call: - outputs: - updated_pr_title: - value: ${{ jobs.prefix-pr-title.outputs.updated_pr_title }} -permissions: - pull-requests: write - -jobs: - prefix-pr-title: - runs-on: ubuntu-latest - outputs: - updated_pr_title: ${{ steps.set_updated_pr_title_output.outputs.updated_pr_title }} - steps: - - name: Check if PR is from Dependabot - run: | - if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then - echo "PR is from Dependabot." - echo "PR_IS_DEPENDABOT=true" >> $GITHUB_ENV - else - echo "PR is not from Dependabot." - echo "PR_IS_DEPENDABOT=false" >> $GITHUB_ENV - fi - - - name: Check if PR title is already prefixed - run: | - if [[ "${{ github.event.pull_request.title }}" =~ ^Upgrade:.*\[dependabot\].*-.*$ ]]; then - echo "PR title is already prefixed." - echo "No change to PR title." - echo "PR_IS_PREFIXED=true" >> $GITHUB_ENV - else - echo "PR title is not prefixed." - echo "PR_IS_PREFIXED=false" >> $GITHUB_ENV - fi - - - name: Check if title should be updated - run: | - if [[ "${{ env.PR_IS_DEPENDABOT }}" == "true" && "${{ env.PR_IS_PREFIXED }}" == "false" ]]; then - echo "PR title should be updated." - echo "PR_UPDATED_TITLE=Upgrade: [dependabot] - ${{ github.event.pull_request.title }}" >> $GITHUB_ENV - else - echo "PR title should not be updated." - echo "No change to PR title." - exit 0 - fi - - - name: Update PR title with Prefix - if: env.PR_UPDATED_TITLE - uses: actions/github-script@v7.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - console.log("Updating PR title to: ${{ env.PR_UPDATED_TITLE }}") - - github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number, - title: "${{ env.PR_UPDATED_TITLE }}" - }) - - - name: Set Updated PR Title as Output - if: env.PR_UPDATED_TITLE - id: set_updated_pr_title_output - run: | - echo "updated_pr_title=${{ env.PR_UPDATED_TITLE }}" >> $GITHUB_OUTPUT diff --git a/package-lock.json b/package-lock.json index c53e90d..ababd29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "semantic-release": "^23.0.0", "ts-jest": "^29.1.1", "ts-node": "^10.4.0", - "typescript": "^5.3.3" + "typescript": "^4.4.3" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -13429,16 +13429,16 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=14.17" + "node": ">=4.2.0" } }, "node_modules/uglify-js": { diff --git a/package.json b/package.json index 3c5c556..f3db833 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "semantic-release": "^23.0.0", "ts-jest": "^29.1.1", "ts-node": "^10.4.0", - "typescript": "^5.3.3" + "typescript": "^4.4.3" }, "dependencies": { "@aws-lambda-powertools/logger": "^1.17.0",