Skip to content

chore(deps): update dependency semantic-release to v25.0.2 #19

chore(deps): update dependency semantic-release to v25.0.2

chore(deps): update dependency semantic-release to v25.0.2 #19

Workflow file for this run

name: PR Label Listener
permissions:
issues: write
actions: write
pull-requests: write
on:
pull_request:
types: [labeled, unlabeled]
jobs:
handle_label:
runs-on: ubuntu-latest
steps:
- name: Check for publish-pr label event
uses: actions/github-script@v8
with:
script: |
const label = context.payload.label?.name;
const prNumber = context.payload.pull_request?.number;
if (label === 'publish-pr' && context.payload.action === 'labeled') {
github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: ':label: The `publish-pr` label was added. The JAR will be attached on next build.'
});
}
if (label === 'publish-pr' && context.payload.action === 'unlabeled') {
// Find workflow runs for this PR
const runs = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
event: 'pull_request',
branch: context.payload.pull_request.head.ref
});
// Find latest run for this PR
const run = runs.data.workflow_runs.find(r => r.head_branch === context.payload.pull_request.head.ref && r.status === 'completed');
if (run) {
// List artifacts for the run
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id
});
const jarArtifact = artifacts.data.artifacts.find(a => a.name === 'pr-jar');
if (jarArtifact) {
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: jarArtifact.id
});
github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: ':wastebasket: The `publish-pr` label was removed. The JAR artifact has been deleted.'
});
} else {
github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: ':warning: The `publish-pr` label was removed, but no JAR artifact was found to delete.'
});
}
} else {
github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: ':warning: The `publish-pr` label was removed, but no completed workflow run was found.'
});
}
}