Skip to content

Commit 7685e2b

Browse files
committed
delete-on-pr-close
1 parent 7e409cb commit 7685e2b

File tree

1 file changed

+63
-49
lines changed

1 file changed

+63
-49
lines changed

.github/workflows/help-command.yml

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ jobs:
1818
EVENT_NAME: ${{ github.event_name }}
1919
IS_PR: ${{ toJSON(github.event.issue.pull_request) }}
2020
COMMENT: ${{ github.event.comment.body }}
21+
ISSUE_NUMBER: ${{ github.event.issue.number }}
2122
run: |
2223
echo "Debug information for help command:"
2324
echo "Event name: $EVENT_NAME"
2425
echo "Is PR (raw): $IS_PR"
2526
echo "Comment body: $COMMENT"
27+
echo "Issue number: $ISSUE_NUMBER"
2628
echo "Raw event payload:"
2729
echo '${{ toJSON(github.event) }}'
2830
@@ -39,52 +41,64 @@ jobs:
3941
uses: actions/github-script@v7
4042
with:
4143
script: |
42-
const helpMessage = [
43-
'## 📚 Available Commands',
44-
'',
45-
'### `/deploy`',
46-
'Deploys your PR branch to a review environment on Control Plane.',
47-
'- Creates a new review app if one doesn\'t exist',
48-
'- Updates the existing review app if it already exists',
49-
'- Provides a unique URL to preview your changes',
50-
'- Shows build and deployment progress in real-time',
51-
'',
52-
'**Required Environment Variables:**',
53-
'- `CPLN_TOKEN`: Control Plane authentication token',
54-
'- `CPLN_ORG`: Control Plane organization name',
55-
'',
56-
'**Optional Configuration:**',
57-
'- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)',
58-
' - Must be a positive integer',
59-
' - Can be set in GitHub Actions variables',
60-
' - Applies to both deployment and workload readiness checks',
61-
'',
62-
'### `/delete-review-app`',
63-
'Deletes the review app associated with this PR.',
64-
'- Removes all resources from Control Plane',
65-
'- Helpful for cleaning up when you\'re done testing',
66-
'- Can be re-deployed later using `/deploy`',
67-
'',
68-
'**Required Environment Variables:**',
69-
'- `CPLN_TOKEN`: Control Plane authentication token',
70-
'- `CPLN_ORG`: Control Plane organization name',
71-
'',
72-
'### `/help`',
73-
'Shows this help message explaining available commands and configuration.',
74-
'',
75-
'---',
76-
'**Note:** These commands only work in pull request comments.',
77-
'',
78-
'**Environment Setup:**',
79-
'1. Set required secrets in your repository settings:',
80-
' - `CPLN_TOKEN`',
81-
' - `CPLN_ORG`',
82-
'2. Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout'
83-
].join('\n');
84-
85-
await github.rest.issues.createComment({
86-
owner: context.repo.owner,
87-
repo: context.repo.repo,
88-
issue_number: context.payload.issue.number,
89-
body: helpMessage
90-
});
44+
try {
45+
console.log('Creating help message...');
46+
const helpMessage = [
47+
'## 📚 Available Commands',
48+
'',
49+
'### `/deploy`',
50+
'Deploys your PR branch to a review environment on Control Plane.',
51+
'- Creates a new review app if one doesn\'t exist',
52+
'- Updates the existing review app if it already exists',
53+
'- Provides a unique URL to preview your changes',
54+
'- Shows build and deployment progress in real-time',
55+
'',
56+
'**Required Environment Variables:**',
57+
'- `CPLN_TOKEN`: Control Plane authentication token',
58+
'- `CPLN_ORG`: Control Plane organization name',
59+
'',
60+
'**Optional Configuration:**',
61+
'- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)',
62+
' - Must be a positive integer',
63+
' - Can be set in GitHub Actions variables',
64+
' - Applies to both deployment and workload readiness checks',
65+
'',
66+
'### `/delete-review-app`',
67+
'Deletes the review app associated with this PR.',
68+
'- Removes all resources from Control Plane',
69+
'- Helpful for cleaning up when you\'re done testing',
70+
'- Can be re-deployed later using `/deploy`',
71+
'',
72+
'**Required Environment Variables:**',
73+
'- `CPLN_TOKEN`: Control Plane authentication token',
74+
'- `CPLN_ORG`: Control Plane organization name',
75+
'',
76+
'### `/help`',
77+
'Shows this help message explaining available commands and configuration.',
78+
'',
79+
'---',
80+
'**Note:** These commands only work in pull request comments.',
81+
'',
82+
'**Environment Setup:**',
83+
'1. Set required secrets in your repository settings:',
84+
' - `CPLN_TOKEN`',
85+
' - `CPLN_ORG`',
86+
'2. Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout'
87+
].join('\n');
88+
89+
console.log('Issue number:', github.context.payload.issue.number);
90+
console.log('Owner:', context.repo.owner);
91+
console.log('Repo:', context.repo.repo);
92+
93+
await github.rest.issues.createComment({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
issue_number: github.context.payload.issue.number,
97+
body: helpMessage
98+
});
99+
100+
console.log('Help message posted successfully');
101+
} catch (error) {
102+
console.error('Error posting help message:', error);
103+
core.setFailed(`Failed to post help message: ${error.message}`);
104+
}

0 commit comments

Comments
 (0)