|
| 1 | +# Changelog Example |
| 2 | + |
| 3 | +This project contains an example on how to generate a changelog using ApexDocs.' |
| 4 | + |
| 5 | +It has 2 directories: `previous`, which contains the previous version of the project, and `current`, which contains the current version of the project. |
| 6 | + |
| 7 | +By running the following command, you can generate a changelog between the two versions: |
| 8 | + |
| 9 | +```bash |
| 10 | +apexdocs changelog --previousVersionDir previous --currentVersionDir current |
| 11 | +``` |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Generating PR Comments with Changelog Information |
| 16 | + |
| 17 | +One example of how to use the changelog feature is to generate a changelog for a pull request. |
| 18 | + |
| 19 | +You can achieve this through Github Actions by using a workflow that looks as follows: |
| 20 | + |
| 21 | +```yaml |
| 22 | +on: |
| 23 | + pull_request: |
| 24 | + branches: [ main ] |
| 25 | + types: [ opened, reopened, synchronize, closed ] |
| 26 | + |
| 27 | +jobs: |
| 28 | + comment-pr: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + name: Comment PR |
| 31 | + permissions: |
| 32 | + pull-requests: write |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v3 |
| 36 | + |
| 37 | + - name: Checkout previous version |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + ref: ${{ github.event.pull_request.base.ref }} |
| 41 | + path: previous |
| 42 | + |
| 43 | + - uses: actions/setup-node@v2 |
| 44 | + with: |
| 45 | + node-version: "20" |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: npm install |
| 49 | + |
| 50 | + - name: Install ApexDocs globally |
| 51 | + run: npm install @cparra/apexdocs --global |
| 52 | + |
| 53 | + - name: Generate changelog |
| 54 | + # Change the previousVersionDir and currentVersionDir to match your project structure |
| 55 | + run: apexdocs changelog --currentVersionDir force-app --previousVersionDir './previous/force-app' --targetDir './changelog' |
| 56 | + |
| 57 | + - name: Comment PR |
| 58 | + uses: thollander/actions-comment-pull-request@v2 |
| 59 | + with: |
| 60 | + # Providing a comment_tag will update the comment if it already exists |
| 61 | + comment_tag: 'changelog' |
| 62 | + filePath: './changelog/changelog.md' |
| 63 | +``` |
0 commit comments