Skip to content

Commit cac41c4

Browse files
committed
Fixed failure to deploy to review app
Invalid workflow file: .github/workflows/deploy-to-control-plane-review.yml#L19 The workflow is not valid. .github/workflows/deploy-to-control-plane-review.yml (Line: 19, Col: 15): Unrecognized named-value: 'steps'. Located at position 1 within expression: steps.get_job_id.outputs.job_id
1 parent 084f0d0 commit cac41c4

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

.github/workflows/deploy-to-control-plane-review.yml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ env:
1616
CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}}
1717
CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}}
1818
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
19-
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ steps.get_job_id.outputs.job_id }}?pr=${{ github.event.pull_request.number || github.event.issue.number }}
2019

2120
jobs:
2221
check-concurrent:
@@ -55,43 +54,36 @@ jobs:
5554
deployment_id: ${{ steps.create-deployment.outputs.result }}
5655

5756
steps:
58-
- name: Get job ID
59-
id: get_job_id
57+
- name: Create initial comment and get job URL
58+
id: init
6059
uses: actions/github-script@v7
6160
with:
6261
script: |
62+
// Get the job ID from the Actions API
6363
const { data: jobs } = await github.rest.actions.listJobsForWorkflowRun({
6464
owner: context.repo.owner,
6565
repo: context.repo.repo,
6666
run_id: context.runId,
6767
});
6868
6969
const currentJob = jobs.jobs.find(job => job.name === context.job);
70-
const jobId = currentJob.id;
71-
72-
return jobId;
73-
74-
- name: Create comment
75-
id: create-comment
76-
uses: actions/github-script@v7
77-
env:
78-
JOB_ID: ${{ steps.get_job_id.outputs.result }}
79-
with:
80-
script: |
81-
async function createComment(message) {
82-
await github.rest.issues.createComment({
83-
issue_number: context.issue.number || context.payload.pull_request.number,
84-
owner: context.repo.owner,
85-
repo: context.repo.repo,
86-
body: message
87-
});
70+
if (!currentJob) {
71+
throw new Error('Could not find current job in the workflow run');
8872
}
8973
74+
const statusUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${currentJob.id}?pr=${context.issue.number || context.payload.pull_request.number}`;
75+
core.exportVariable('statusUrl', statusUrl);
76+
9077
const message = `🚀 Starting new deployment for commit: ${context.sha.substring(0, 7)}
9178
${context.payload.commits ? `\nChanges: ${context.payload.commits[0].message}` : ''}
92-
Status: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${JOB_ID}?pr=${context.issue.number || context.payload.pull_request.number}`;
79+
Status: ${statusUrl}`;
9380
94-
await createComment(message);
81+
await github.rest.issues.createComment({
82+
issue_number: context.issue.number || context.payload.pull_request.number,
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
body: message
86+
});
9587
9688
- name: Create GitHub Deployment
9789
id: create-deployment
@@ -148,7 +140,7 @@ jobs:
148140
app_name: ${{ env.APP_NAME }}
149141
org: ${{ env.CPLN_ORG }}
150142

151-
- name: Update deployment status (success)
143+
- name: Update deployment status success
152144
if: success()
153145
uses: actions/github-script@v7
154146
with:
@@ -157,9 +149,14 @@ jobs:
157149
Environment: review-app
158150
Commit: ${context.sha.substring(0, 7)}
159151
URL: ${{ steps.deploy.outputs.app_url }}
160-
Status: ${{ env.STATUS_URL }}`;
152+
Status: ${process.env.statusUrl}`;
161153
162-
await eval(process.env.createComment)(message);
154+
await github.rest.issues.createComment({
155+
issue_number: context.issue.number || context.payload.pull_request.number,
156+
owner: context.repo.owner,
157+
repo: context.repo.repo,
158+
body: message
159+
});
163160
164161
await github.rest.repos.createDeploymentStatus({
165162
owner: context.repo.owner,
@@ -170,16 +167,21 @@ jobs:
170167
description: 'Deployment successful'
171168
});
172169
173-
- name: Update deployment status (failure)
170+
- name: Update deployment status failure
174171
if: failure()
175172
uses: actions/github-script@v7
176173
with:
177174
script: |
178175
const message = `❌ Deployment failed
179176
Commit: ${context.sha.substring(0, 7)}
180-
Status: ${{ env.STATUS_URL }}`;
177+
Status: ${process.env.statusUrl}`;
181178
182-
await eval(process.env.createComment)(message);
179+
await github.rest.issues.createComment({
180+
issue_number: context.issue.number || context.payload.pull_request.number,
181+
owner: context.repo.owner,
182+
repo: context.repo.repo,
183+
body: message
184+
});
183185
184186
await github.rest.repos.createDeploymentStatus({
185187
owner: context.repo.owner,

0 commit comments

Comments
 (0)