Skip to content

updating the initial sync and healthchecks #30

updating the initial sync and healthchecks

updating the initial sync and healthchecks #30

name: Generate Release Content
on:
pull_request:
branches:
- main
jobs:
label:
runs-on: ubuntu-latest
outputs:
release-type: ${{ steps.parse-labels.outputs.release-type }}
change-type: ${{ steps.parse-labels.outputs.change-type }}
previous-version: ${{ steps.prevtag.outputs.previousversion }}
release-version: ${{ steps.new-version-standard.outputs.new-version }}
changelog-content: ${{ steps.set-changelog.outputs.changelog }}
permissions:
issues: write
pull-requests: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: src
fetch-depth: 0
- name: Parse and Add Labels
id: parse-labels
uses: actions/github-script@v7
with:
script: |
const script = require('./src/.github/scripts/pr-scripts/parse-add-labels.js')
await script({github, context, core})
- name: Detect previous version number
id: prevtag
working-directory: src
run: |
if previousversion=$(git describe --tags --match="[0-9]*" --abbrev=0 HEAD 2>/dev/null); then
echo "previousversion=$(git describe --tags --match="[0-9]*" --abbrev=0 HEAD)" >> "$GITHUB_OUTPUT"
else
echo "previousversion=0.0.0" >> "$GITHUB_OUTPUT"
fi
- name: Determine new version number (Standard)
uses: actions/github-script@v7
id: new-version-standard
env:
PREV_VERSION: ${{ steps.prevtag.outputs.previousversion }}
RELEASE_TYPE: ${{ steps.parse-labels.outputs.release-type }}
with:
script: |
const script = require('./src/.github/scripts/pr-scripts/plan_new-version.js')
await script({github, context, core})
- name: Extract changelog entry
uses: actions/github-script@v7
id: set-changelog
env:
releaseversion: ${{ steps.new-version-standard.outputs.new-version }}
changetype: ${{ steps.parse-labels.outputs.change-type }}
with:
script: |
const script = require('./src/.github/scripts/pr-scripts/plan_changelog.js')
await script({github, context, core})
comment:
needs: label
if: needs.label.outputs.release-type != 'no-release'
permissions:
issues: write
pull-requests: write
contents: read
runs-on: ubuntu-latest
name: 'Comment on PR'
steps:
- name: Clone Repo to determine previous git tag
uses: actions/checkout@v4
with:
path: src
fetch-depth: 0
- uses: actions/github-script@v7
env:
releaseVersion: '${{ needs.label.outputs.release-version }}'
previousVersion: '${{ needs.label.outputs.previous-version }}'
changelogContent: '${{ needs.label.outputs.changelog-content }}'
with:
script: |
const script = require('./src/.github/scripts/pr-scripts/comment_pr-comment.js')
await script({github, context, core})
update-files:
needs: label
permissions:
issues: write
pull-requests: write
contents: write
runs-on: ubuntu-latest
name: 'Update release files.'
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
with:
path: src
fetch-depth: 0
ref: 'main'
- name: Fetch Release Notes
id: fetch-release-notes
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const readFile = (filePath) => fs.readFileSync(filePath, 'utf-8').trim();
const changelogPath = 'src/CHANGELOG.md';
const changelogContent = readFile(changelogPath);
core.setOutput('existing-changelog', changelogContent);
- name: Prepend New Changelog Content
id: prepend-changelog
run: |
mkdir -p tmp && cd tmp
echo "# Changelog" > updated-changelog.md
echo "" >> updated-changelog.md
printf "${{ needs.label.outputs.changelog-content }}" >> updated-changelog.md
printf "${{ steps.fetch-release-notes.outputs.existing-changelog }}" | sed '1d' >> updated-changelog.md
- name: Generate Readme Content
working-directory: src
run: |
npm install js-yaml --save
node .github/scripts/generate-readme.js
- name: Checkout Pull Request Branch Again
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
path: src
- name: Update package.json with version
working-directory: src
run: |
sed -i 's/"version": "[^"]*"/"version": "${{ needs.label.outputs.release-version }}"/' package.json
- name: Commit and Push Updates
working-directory: src
run: |
git config user.name "GitHub-Actions[bot]"
git config user.email "GitHub-Actions[bot]@users.noreply.github.com"
cp ${{ github.workspace }}/tmp/updated-changelog.md CHANGELOG.md
cp ${{ github.workspace }}/tmp/new-README.md README.md
git add CHANGELOG.md README.md package.json
if ! git diff-index --quiet HEAD; then
git commit -m "Bot: Updating CHANGELOG, README and package.json for release based on #${{ github.event.pull_request.number }}"
git push origin ${{ github.event.pull_request.head.ref }}
fi