Skip to content

Commit

Permalink
Add release notes automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung committed Mar 6, 2024
1 parent eb32b7a commit aa4cf67
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

deploy-dev:
name: Deploy dev
needs: [validation, tag, build-front-artefact, build-back-artefact]
needs: [ validation, tag, build-front-artefact, build-back-artefact ]
uses: ./.github/workflows/deploy-to-scalingo.yml
with:
environment: dev
Expand Down Expand Up @@ -74,3 +74,13 @@ jobs:
secrets:
SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}

create-release-notes:
name: Create release notes
needs: deploy-prod
uses: ./.github/workflows/create-release-notes.yml
with:
tag: "v${{ github.run_number }}"
repository: ${{ github.repository }}
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 50 additions & 0 deletions .github/workflows/create-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create release notes

on:
workflow_call:
inputs:
tag:
type: string
required: true
repository:
type: string
required: true
secrets:
GITHUB_TOKEN:
required: true

jobs:
create-release-notes:
name: Create release notes
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get tag of latest release
id: get-latest-release-tag
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const latestRelease = await github.request(`GET /repos/${{ inputs.repository }}/releases/latest`)
return latestRelease.data.tag_name
result-encoding: string
- name: Generate release notes from latest release
id: generate-release-notes
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const releaseNotes = await github.request(`POST /repos/${{ inputs.repository }}/releases/generate-notes`, {
tag_name: `${{ inputs.tag }}`,
previous_tag_name: `${{steps.get-latest-release-tag.outputs.result}}` })
return releaseNotes.data
- name: Create release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.request(`POST /repos/${{ inputs.repository }}/releases`, {
tag_name: `${{ inputs.tag }}`,
name: `${{fromJson(steps.generate-release-notes.outputs.result).name}}`,
body: `${{fromJson(steps.generate-release-notes.outputs.result).body}}`})

0 comments on commit aa4cf67

Please sign in to comment.