|
| 1 | +name: Check Changelog |
| 2 | + |
| 3 | +inputs: |
| 4 | + base-branch: |
| 5 | + description: 'The base branch to compare against' |
| 6 | + required: false |
| 7 | + default: 'main' |
| 8 | + head-ref: |
| 9 | + description: 'The head ref to check out' |
| 10 | + required: true |
| 11 | + labels: |
| 12 | + description: 'JSON string of PR labels' |
| 13 | + required: true |
| 14 | + pr-number: |
| 15 | + description: 'The pull request number' |
| 16 | + required: true |
| 17 | + repo: |
| 18 | + description: 'The repository to check' |
| 19 | + required: true |
| 20 | + github-tools-repository: |
| 21 | + description: 'The GitHub repository containing the GitHub tools. Defaults to the GitHub tools action repositor, and usually does not need to be changed.' |
| 22 | + required: false |
| 23 | + default: ${{ github.action_repository }} |
| 24 | + github-tools-ref: |
| 25 | + description: 'The SHA of the action to use. Defaults to the current action ref, and usually does not need to be changed.' |
| 26 | + required: false |
| 27 | + default: ${{ github.action_ref }} |
| 28 | + |
| 29 | +runs: |
| 30 | + using: composite |
| 31 | + steps: |
| 32 | + - name: Check PR Labels |
| 33 | + id: label-check |
| 34 | + env: |
| 35 | + PR_LABELS: ${{ inputs.labels }} |
| 36 | + run: | |
| 37 | + if echo "$PR_LABELS" | jq -e '.[] | select(.name == "no-changelog")' > /dev/null; then |
| 38 | + echo "no-changelog label found, skipping changelog check." |
| 39 | + echo "skip_check=true" >> "$GITHUB_OUTPUT" |
| 40 | + else |
| 41 | + echo "No no-changelog label found, proceeding with check." |
| 42 | + echo "skip_check=false" >> "$GITHUB_OUTPUT" |
| 43 | + fi |
| 44 | + shell: bash |
| 45 | + |
| 46 | + - name: Check out target repository |
| 47 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 48 | + uses: actions/checkout@v5 |
| 49 | + with: |
| 50 | + repository: ${{ inputs.repo }} |
| 51 | + ref: ${{ inputs.head-ref }} |
| 52 | + path: target-repo |
| 53 | + fetch-depth: 0 |
| 54 | + |
| 55 | + - name: Debug log |
| 56 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 57 | + env: |
| 58 | + ACTION_REPOSITORY: ${{ inputs.github-tools-repository }} |
| 59 | + ACTION_REF: ${{ inputs.github-tools-ref }} |
| 60 | + run: | |
| 61 | + echo "ACTION_REPOSITORY: $ACTION_REPOSITORY" |
| 62 | + echo "ACTION_REF: $ACTION_REF" |
| 63 | + shell: bash |
| 64 | + |
| 65 | + - name: Checkout GitHub tools repository |
| 66 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 67 | + uses: actions/checkout@v5 |
| 68 | + with: |
| 69 | + repository: ${{ inputs.github-tools-repository }} |
| 70 | + ref: ${{ inputs.github-tools-ref }} |
| 71 | + path: ./.github-tools |
| 72 | + |
| 73 | + - name: Enable Corepack |
| 74 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 75 | + run: corepack enable |
| 76 | + shell: bash |
| 77 | + working-directory: ./.github-tools |
| 78 | + |
| 79 | + - name: Set up Node.js |
| 80 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 81 | + uses: actions/setup-node@v4 |
| 82 | + with: |
| 83 | + node-version-file: ./.github-tools/.nvmrc |
| 84 | + cache-dependency-path: ./.github-tools/yarn.lock |
| 85 | + cache: yarn |
| 86 | + |
| 87 | + - name: Install dependencies |
| 88 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 89 | + run: yarn --immutable |
| 90 | + shell: bash |
| 91 | + working-directory: ./.github-tools |
| 92 | + |
| 93 | + - name: Check Changelog |
| 94 | + if: ${{ steps.label-check.outputs.skip_check != 'true' }} |
| 95 | + id: changelog-check |
| 96 | + shell: bash |
| 97 | + working-directory: ./.github-tools |
| 98 | + env: |
| 99 | + BASE_BRANCH: ${{ inputs.base-branch }} |
| 100 | + PR_NUMBER: ${{ inputs.pr-number }} |
| 101 | + run: | |
| 102 | + yarn run changelog:check ../target-repo "$BASE_BRANCH" "$PR_NUMBER" |
0 commit comments