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 # Run a build step here if your project requires
- name: Publish to Cloudflare Pages - name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@1 uses: cloudflare/pages-action@v1
with: with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: YOUR_ACCOUNT_ID accountId: YOUR_ACCOUNT_ID

@ -22128,6 +22128,28 @@ try {
state: "success" 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 () => { (async () => {
const project = await getProject(); const project = await getProject();
if (!project) if (!project)
@ -22149,6 +22171,7 @@ try {
alias = pagesDeployment.aliases[0]; alias = pagesDeployment.aliases[0];
} }
(0, import_core.setOutput)("alias", alias); (0, import_core.setOutput)("alias", alias);
await createJobSummary({ deployment: pagesDeployment, aliasUrl: alias });
if (gitHubDeployment) { if (gitHubDeployment) {
const octokit = (0, import_github.getOctokit)(gitHubToken); const octokit = (0, import_github.getOctokit)(gitHubToken);
await createGitHubDeploymentStatus({ 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 type { Project, Deployment } from '@cloudflare/types';
import { context, getOctokit } from "@actions/github"; import { context, getOctokit } from "@actions/github";
import shellac from "shellac"; 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 () => { (async () => {
const project = await getProject(); const project = await getProject();
if (!project) throw new Error('Unable to find pages project') if (!project) throw new Error('Unable to find pages project')
@ -106,7 +139,7 @@ try {
const octokit = getOctokit(gitHubToken); const octokit = getOctokit(gitHubToken);
gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, environmentName); gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, environmentName);
} }
const pagesDeployment = await createPagesDeployment(); const pagesDeployment = await createPagesDeployment();
setOutput("id", pagesDeployment.id); setOutput("id", pagesDeployment.id);
setOutput("url", pagesDeployment.url); setOutput("url", pagesDeployment.url);
@ -118,6 +151,8 @@ try {
} }
setOutput("alias", alias); setOutput("alias", alias);
await createJobSummary({ deployment: pagesDeployment, aliasUrl: alias });
if (gitHubDeployment) { if (gitHubDeployment) {
const octokit = getOctokit(gitHubToken); const octokit = getOctokit(gitHubToken);

Loading…
Cancel
Save