Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
reakaleek committed Jan 22, 2025
1 parent a976288 commit 9657bdb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/preview-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,32 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const deployments = await github.rest.repos.listDeployments({
owner: context.repo.owner,
repo: context.repo.repo,
owner,
repo,
environment: `preview-${context.issue.number}`
});
for (const deployment of deployments.data) {
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
owner,
repo,
deployment_id: deployment.id,
state: 'inactive',
description: 'Marking deployment as inactive'
});
await github.rest.repos.deleteDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
owner,
repo,
deployment_id: deployment.id
});
}
octokit.rest.repos.deleteAnEnvironment({
owner,
repo,
environment_name: `preview-${context.issue.number}`,
});

9 changes: 5 additions & 4 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
with:
result-encoding: string
script: |
const { owner, repo } = context.repo;
const deployment = await github.rest.repos.createDeployment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
owner,
repo,
ref: context.payload.pull_request.head.ref,
environment: `preview-${context.issue.number}`,
description: `Preview deployment for PR ${context.issue.number}`,
Expand All @@ -30,8 +31,8 @@ jobs:
})
await github.rest.repos.createDeploymentStatus({
deployment_id: deployment.data.id,
owner: context.repo.owner,
repo: context.repo.repo,
owner,
repo,
state: "in_progress",
description: "Deployment created",
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
Expand Down

0 comments on commit 9657bdb

Please sign in to comment.