Skip to content

update-common-package-event #31

update-common-package-event

update-common-package-event #31

Workflow file for this run

name: Update doc-detective-common version
on:
repository_dispatch:
types:
- update-common-package-event
workflow_dispatch:
inputs:
version:
description: 'The doc-detective-common version.'
required: false
default: 'latest'
jobs:
update:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.DD_DEP_UPDATE_TOKEN }}
- name: Set version variable
id: version
run: |
VERSION="${{ github.event.client_payload.version || github.event.inputs.version || 'latest' }}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Using version: $VERSION"
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Install specific version of doc-detective-common
run: |
npm install doc-detective-common@${{ steps.version.outputs.version }} || {
echo "Failed to install doc-detective-common@${{ steps.version.outputs.version }}"
exit 1
}
- name: Test the installation
run: |
npm test
- name: Commit changes
id: commit
run: |
git add package.json package-lock.json
if git diff --staged --quiet; then
echo "No changes to commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
git commit -m "chore: bump doc-detective-common version to ${{ steps.version.outputs.version }}"
git push
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Bump patch version
id: patch
if: steps.commit.outputs.has_changes == 'true'
run: |
git checkout -- .
git clean -fd
npm version patch
git push
git push --tags
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Create release
if: steps.commit.outputs.has_changes == 'true'
uses: softprops/action-gh-release@v2
with:
body: "Updated doc-detective-common to v${{ steps.patch.outputs.version }}."
tag_name: "v${{ steps.patch.outputs.version }}"
name: "v${{ steps.patch.outputs.version }}"
generate_release_notes: true
token: ${{ secrets.DD_DEP_UPDATE_TOKEN }}