From e80ac4ce980918daabcc7e003b37d59bfd2d139d Mon Sep 17 00:00:00 2001 From: Daniel Levi-Minzi Date: Fri, 27 Sep 2024 13:56:42 -0400 Subject: [PATCH] test safe failure --- .github/workflows/release-changelog.yml | 32 ++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-changelog.yml b/.github/workflows/release-changelog.yml index 465e29188..8837222fd 100644 --- a/.github/workflows/release-changelog.yml +++ b/.github/workflows/release-changelog.yml @@ -3,6 +3,10 @@ name: Auto Changelog PR on: release: types: [published, created] + workflow_dispatch: # Add this line to allow manual triggering + push: + branches: + - eli/automated-changelog jobs: changelog: @@ -36,9 +40,24 @@ jobs: }).format(date); } - const release = context.payload.release; + # const release = context.payload.release; + + const release = { + name: 'Beta 9', + body: 'This is a test release that should not be published', + created_at: '2024-02-29T12:00:00Z' + }; + const lines = release.body.split('\n'); + // Stop the workflow if the release notes do not end with "publish changelog" + const lastLine = lines[lines.length - 1].trim().toLowerCase(); + if (lastLine !== 'publish changelog') { + core.setOutput('should_continue', 'false'); + core.setOutput('error_message', 'Release notes do not end with "publish changelog". Stopping workflow.'); + return; + } + const feats = []; const fixes = []; for (const line of lines) { @@ -59,6 +78,13 @@ jobs: } } + // Stop the workflow if no features or fixes are found + if (feats.length === 0 && fixes.length === 0) { + core.setOutput('should_continue', 'false'); + core.setOutput('error_message', 'No features or fixes found in the release notes. Stopping workflow.'); + return; + } + const featsString = feats.map(feat => `- ${feat}`).join('\n'); const fixesString = fixes.map(fix => `- ${fix}`).join('\n'); @@ -69,6 +95,7 @@ jobs: core.setOutput('pretty_date', prettyDate(release.created_at)); - name: Checkout beam-docs repo + if: steps.release.outputs.should_continue == 'true' uses: actions/checkout@v3 with: repository: slai-labs/beam-docs @@ -76,6 +103,7 @@ jobs: token: ${{ secrets.BEAM_DOCS_PAT }} - name: Create new release file in beam-docs + if: steps.release.outputs.should_continue == 'true' run: | cd beam-docs/v2/releases FILENAME="${{ steps.release.outputs.created_at }}.mdx" @@ -93,6 +121,7 @@ jobs: echo "" >> $FILENAME - name: Commit and push changes + if: steps.release.outputs.should_continue == 'true' run: | cd beam-docs git config --global user.name "github-actions" @@ -103,6 +132,7 @@ jobs: git push -u origin autochangelog/${{ steps.release.outputs.name }} - name: Create pull request + if: steps.release.outputs.should_continue == 'true' env: GH_TOKEN: ${{ secrets.BEAM_DOCS_PAT }} run: |