From 4f2cbf9f90b8bf937cf55fbf940cc413e7a3d598 Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:35:02 +0100 Subject: [PATCH] wef --- .github/workflows/release-changelog.yml | 52 +++++++++++-------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release-changelog.yml b/.github/workflows/release-changelog.yml index 692b9ed1fe..2da697cc4d 100644 --- a/.github/workflows/release-changelog.yml +++ b/.github/workflows/release-changelog.yml @@ -1,43 +1,35 @@ -name: Release changelog +name: Release Changelog on: pull_request: branches: - master - types: [ opened, synchronize, reopened ] + types: [opened, synchronize] jobs: release-changelog: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install dependencies - run: npm install -g conventional-changelog-cli - - - name: Generate Changelog - id: changelog - run: echo "::set-output name=changelog::$(conventional-changelog -s)" + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Important pour s'assurer que tous les commits sont récupérés - - name: Get PR Number - run: echo "::set-output name=pr_number::${{ github.event.pull_request.number }}" + - name: Generate changelog + id: generate_changelog + run: | + # Utilisez git pour extraire les messages de commit entre cette branche et master + CHANGELOG=$(git log origin/master.. --oneline --no-merges) + # Formatage pour Markdown (commentaire GitHub) + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=changelog::$CHANGELOG" - - name: Update PR comment - uses: actions/github-script@v4 + - name: Comment on PR + uses: thollander/actions-comment-pull-request@v1 with: - script: | - const fs = require('fs'); - const prNumber = process.env.PR_NUMBER; - const changelog = fs.readFileSync('changelog.txt', 'utf8'); // assuming changelog output is stored in a file - const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - octokit.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: `Changelog has been updated. You can review it [here](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md).\n\nChangelog:\n${changelog}` - }); - env: - PR_NUMBER: ${{ steps.pr_number.outputs.pr_number }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + message: | + ## Changelog + ${{ steps.generate_changelog.outputs.changelog }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}