Job summary (#44)

pull/45/head
Daniel Walsh 2 years ago committed by GitHub
parent b3c3fa6f93
commit 1b484b8e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,7 @@ GitHub Action for creating Cloudflare Pages deployments, using the new [Direct U
# Run a build step here if your project requires
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@1
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID

@ -22128,6 +22128,28 @@ try {
state: "success"
});
};
const createJobSummary = async ({
deployment,
aliasUrl
}) => {
const deployStage = deployment.stages.find((stage) => stage.name === "deploy");
let status = "\u26A1\uFE0F Deployment in progress...";
if (deployStage?.status === "success") {
status = "\u2705 Deploy successful!";
} else if (deployStage?.status === "failure") {
status = "\u{1F6AB} Deployment failed";
}
await import_core.summary.addRaw(`
# Deploying with Cloudflare Pages
| Name | Result |
| ----------------------- | - |
| **Last commit:** | \`${deployment.deployment_trigger.metadata.commit_hash.substring(0, 8)}\` |
| **Status**: | ${status} |
| **Preview URL**: | ${deployment.url} |
| **Branch Preview URL**: | ${aliasUrl} |
`).write();
};
(async () => {
const project = await getProject();
if (!project)
@ -22149,6 +22171,7 @@ try {
alias = pagesDeployment.aliases[0];
}
(0, import_core.setOutput)("alias", alias);
await createJobSummary({ deployment: pagesDeployment, aliasUrl: alias });
if (gitHubDeployment) {
const octokit = (0, import_github.getOctokit)(gitHubToken);
await createGitHubDeploymentStatus({

@ -1,4 +1,4 @@
import { getInput, setOutput, setFailed } from "@actions/core";
import { getInput, setOutput, setFailed, summary } from "@actions/core";
import type { Project, Deployment } from '@cloudflare/types';
import { context, getOctokit } from "@actions/github";
import shellac from "shellac";
@ -92,6 +92,39 @@ try {
});
};
const createJobSummary = async (
{
deployment,
aliasUrl,
}:
{
deployment: Deployment;
aliasUrl: string;
}
) => {
const deployStage = deployment.stages.find((stage) => stage.name === 'deploy');
let status = '⚡️ Deployment in progress...';
if (deployStage?.status === 'success') {
status = '✅ Deploy successful!';
} else if (deployStage?.status === 'failure') {
status = '🚫 Deployment failed';
}
await summary
.addRaw(`
# Deploying with Cloudflare Pages
| Name | Result |
| ----------------------- | - |
| **Last commit:** | \`${deployment.deployment_trigger.metadata.commit_hash.substring(0, 8)}\` |
| **Status**: | ${status} |
| **Preview URL**: | ${deployment.url} |
| **Branch Preview URL**: | ${aliasUrl} |
`)
.write();
}
(async () => {
const project = await getProject();
if (!project) throw new Error('Unable to find pages project')
@ -106,7 +139,7 @@ try {
const octokit = getOctokit(gitHubToken);
gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, environmentName);
}
const pagesDeployment = await createPagesDeployment();
setOutput("id", pagesDeployment.id);
setOutput("url", pagesDeployment.url);
@ -118,6 +151,8 @@ try {
}
setOutput("alias", alias);
await createJobSummary({ deployment: pagesDeployment, aliasUrl: alias });
if (gitHubDeployment) {
const octokit = getOctokit(gitHubToken);

Loading…
Cancel
Save