Skip to content

Commit

Permalink
test safe failure
Browse files Browse the repository at this point in the history
  • Loading branch information
dleviminzi committed Sep 27, 2024
1 parent 0537977 commit e80ac4c
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion .github/workflows/release-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand All @@ -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');
Expand All @@ -69,13 +95,15 @@ 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
path: beam-docs
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"
Expand All @@ -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"
Expand All @@ -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: |
Expand Down

0 comments on commit e80ac4c

Please sign in to comment.