This commit is contained in:
Jesse Duffield 2025-01-11 15:33:40 +11:00
parent 8773a2b880
commit c96b70c160

View file

@ -20,47 +20,46 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup GitHub CLI
run: |
gh auth setup-git
gh auth status
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for Blocking Issues/PRs - name: Check for Blocking Issues/PRs
id: check_blocks id: check_blocks
uses: actions/github-script@v6 run: |
with: echo "Checking for blocking issues and PRs..."
script: |
// Check for issues with blocks-release label
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'blocks-release',
state: 'open'
});
// Check for PRs with blocks-release label # Check for blocking issues
const { data: prs } = await github.rest.pulls.list({ blocking_issues=$(gh issue list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number))"')
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
const blockingPRs = prs.filter(pr => # Check for blocking PRs
pr.labels.some(label => label.name === 'blocks-release') blocking_prs=$(gh pr list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number)) (PR)"')
);
const blockingItems = [ # Combine the results
...issues.map(issue => `- ${issue.title} (#${issue.number})`), blocking_items="$blocking_issues"$'\n'"$blocking_prs"
...blockingPRs.map(pr => `- ${pr.title} (#${pr.number}) (PR)`)
];
if (blockingItems.length > 0) { # Remove empty lines
core.setOutput('block_release', 'true'); blocking_items=$(echo "$blocking_items" | grep . || true)
core.setOutput('blocking_items', blockingItems.join("\n"));
} else { if [ -n "$blocking_items" ]; then
core.setOutput('block_release', 'false'); echo "block_release=true" >> $GITHUB_OUTPUT
} echo "blocking_items<<EOF" >> $GITHUB_OUTPUT
echo "$blocking_items" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "block_release=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stop if Blocks Exist - name: Stop if Blocks Exist
if: steps.check-blocks.outputs.block_release == 'true' if: steps.check_blocks.outputs.block_release == 'true'
run: | run: |
echo "Blocking issues/PRs detected:" echo "Blocking issues/PRs detected:"
echo "${{ steps.check-blocks.outputs.blocking_items }}" echo "${{ steps.check_blocks.outputs.blocking_items }}"
exit 1 exit 1
# - name: Check for changes since last release # - name: Check for changes since last release
@ -86,11 +85,11 @@ jobs:
echo "New tag: $new_tag" echo "New tag: $new_tag"
echo "new_tag=$new_tag" >> $GITHUB_ENV echo "new_tag=$new_tag" >> $GITHUB_ENV
- name: Push New Tag # - name: Push New Tag
run: | # run: |
git config user.name "github-actions[bot]" # git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" # git config user.email "github-actions[bot]@users.noreply.github.com"
git tag example-${{ env.new_tag }} # git tag example-${{ env.new_tag }}
git push origin ${{ env.new_tag }} # git push origin example-${{ env.new_tag }}
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}