ci: add break to switch statements #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Changeset Automation | |
on: | |
pull_request_target: | |
types: | |
- opened | |
- edited | |
- synchronize | |
- reopened | |
- ready_for_review | |
jobs: | |
auto-changeset: | |
if: | | |
startsWith(github.repository, 'asyncapi/') && | |
(!contains(github.event.pull_request.labels, 'skip-changeset')) && | |
( startsWith(github.event.pull_request.title, 'fix:') || | |
startsWith(github.event.pull_request.title, 'feat:') || | |
startsWith(github.event.pull_request.title, 'fix!:') || | |
startsWith(github.event.pull_request.title, 'feat!:') | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Checkout PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: gh pr checkout ${{ github.event.pull_request.number }} | |
# This step has been added in such a way because | |
# - Using simple `npm install` will install all the packages in the repo, which takes a lot of time. | |
# - Using `npm install` doesn't work with all repositories, as some of them have a different structure/package manager. | |
# - Global installation also doesn't work as can't be imported in the script. | |
- name: Install specific package in temp dir | |
run: | | |
mkdir temp-install | |
cd temp-install | |
npm init -y | |
npm install [email protected] | |
cp -r node_modules ../node_modules | |
cd .. | |
rm -rf temp-install | |
- name: Get changeset contents | |
id: get_changeset_contents | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { getChangesetContents } = require('./.github/workflows/changeset-utils/index.js') | |
const pullRequest = context.payload.pull_request; | |
const changesetContents = await getChangesetContents(pullRequest, github) | |
return changesetContents; | |
- name: Create changeset file | |
run: "echo -e ${{ steps.get_changeset_contents.outputs.result }} > .changeset/${{ github.event.pull_request.number }}.md" | |
- name: Commit changeset file | |
run: | | |
git config --global user.name asyncapi-bot | |
git config --global user.email [email protected] | |
git add .changeset/${{ github.event.pull_request.number }}.md | |
# Check if there are any changes to commit | |
if git diff --quiet HEAD; then | |
echo "No changes to commit" | |
else | |
git commit -m "chore: add changeset for PR #${{ github.event.pull_request.number }}" | |
fi | |
- name: Push changeset file | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
git remote set-url origin https://github.com/${{ github.event.pull_request.head.repo.full_name }} | |
git push origin HEAD:${{ github.event.pull_request.head.ref }} | |
- name: Comment workflow | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { commentWorkflow } = require('./.github/workflows/changeset-utils/index.js') | |
const pullRequest = context.payload.pull_request; | |
const changesetContents = ${{ steps.get_changeset_contents.outputs.result }} | |
await commentWorkflow(pullRequest, github, changesetContents) |