chore: use tabs (#46)

This commit is contained in:
James Ross 2022-12-20 23:03:33 +00:00 committed by GitHub
parent c2ad89679f
commit 1aff065c9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1637 additions and 1635 deletions

10
.editorconfig Normal file
View file

@ -0,0 +1,10 @@
# https://editorconfig.org
root = true
[*]
end_of_line = lf
indent_style = tab
tab_width = 2
[*.yml]
indent_style = space

6
.prettierrc Normal file
View file

@ -0,0 +1,6 @@
{
"printWidth": 120,
"singleQuote": false,
"semi": true,
"useTabs": true
}

View file

@ -38,12 +38,15 @@ GitHub Action for creating Cloudflare Pages deployments, using the new [Direct U
1. Replace `YOUR_ACCOUNT_ID`, `YOUR_PROJECT_NAME` and `YOUR_ASSET_DIRECTORY` with the appropriate values to your Pages project.
### Get account ID
To find your account ID, log in to the Cloudflare dashboard > select your zone in Account Home > find your account ID in Overview under **API** on the right-side menu. If you have not added a zone, add one by selecting **Add site** . You can purchase a domain from [Cloudflares registrar](https://developers.cloudflare.com/registrar/).
If you do not have a zone registered to your account, you can also get your account ID from the `pages.dev` URL. E.g: `https://dash.cloudflare.com/<ACCOUNT_ID>/pages`
### Generate an API Token
To generate an API token:
1. Log in to the Cloudflare dashboard.
2. Select My Profile from the dropdown menu of your user icon on the top right of your dashboard.
3. Select API Tokens > Create Token.
@ -55,6 +58,7 @@ To generate an API token:
More information can be found on [our guide for making Direct Upload deployments with continous integration](https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/#use-github-actions).
### Specifying a branch
The branch name is used by Cloudflare Pages to determine if the deployment is production or preview. Read more about
[git branch build controls](https://developers.cloudflare.com/pages/platform/branch-build-controls/#branch-build-controls).
@ -62,6 +66,7 @@ If you are in a Git workspace, Wrangler will automatically pull the branch infor
manually by adding the argument `branch: YOUR_BRANCH_NAME`.
## Outputs
| Name | Description |
| ------------- | --------------------------------------------------- |
| `id` | The ID of the pages deployment |

View file

@ -19,31 +19,19 @@
<p>Create new deployments using:</p>
<section class="options">
<img src="assets/terminal.svg" />
<a
href="https://dash.cloudflare.com/?to=/:account/pages/new/wrangler-guide"
target="_blank"
> Wrangler CLI</a
>
<a href="https://dash.cloudflare.com/?to=/:account/pages/new/wrangler-guide" target="_blank"> Wrangler CLI</a>
<img src="assets/cloud-upload.svg" />
<a
href="https://dash.cloudflare.com/?to=/:account/pages/new/upload"
target="_blank"
> Dashboard</a
>
<a href="https://dash.cloudflare.com/?to=/:account/pages/new/upload" target="_blank"> Dashboard</a>
</section>
</div>
<section class="learn-more">
<a
href="https://developers.cloudflare.com/pages/platform/direct-uploads"
>
<a href="https://developers.cloudflare.com/pages/platform/direct-uploads">
<button>Learn more</button>
</a>
</section>
<div class="logo">
<a href="https://pages.cloudflare.com/" target="_blank">
<img src="assets/cloudflare-pages.svg"
/></a>
<a href="https://pages.cloudflare.com/" target="_blank"> <img src="assets/cloudflare-pages.svg" /></a>
</div>
</div>
</body>

View file

@ -1,6 +1,7 @@
* {
box-sizing: border-box;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", Arial, sans-serif;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", Arial,
sans-serif;
margin: auto;
}
@ -121,8 +122,7 @@
}
@media screen and (max-width: 600px) {
.container{
.container {
background-size: contain;
background-position-y: center;
}

View file

@ -22128,10 +22128,7 @@ try {
state: "success"
});
};
const createJobSummary = async ({
deployment,
aliasUrl
}) => {
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") {
@ -22139,7 +22136,8 @@ try {
} else if (deployStage?.status === "failure") {
status = "\u{1F6AB} Deployment failed";
}
await import_core.summary.addRaw(`
await import_core.summary.addRaw(
`
# Deploying with Cloudflare Pages
| Name | Result |
@ -22148,7 +22146,8 @@ try {
| **Status**: | ${status} |
| **Preview URL**: | ${deployment.url} |
| **Branch Preview URL**: | ${aliasUrl} |
`).write();
`
).write();
};
(async () => {
const project = await getProject();

14
package-lock.json generated
View file

@ -19,7 +19,7 @@
"@types/node": "^18.11.3",
"esbuild": "^0.15.12",
"husky": "^8.0.1",
"prettier": "^2.6.2",
"prettier": "^2.8.1",
"typescript": "^4.6.4"
}
},
@ -688,9 +688,9 @@
}
},
"node_modules/prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz",
"integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
@ -1222,9 +1222,9 @@
}
},
"prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz",
"integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==",
"dev": true
},
"react": {

View file

@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"build": "npx esbuild src/index.ts --bundle --platform=node --target=es2021 --outfile=index.js",
"prepare": "husky install"
"prepare": "husky install",
"prettify": "prettier . --write --ignore-unknown"
},
"repository": {
"type": "git",
@ -31,7 +32,7 @@
"@types/node": "^18.11.3",
"esbuild": "^0.15.12",
"husky": "^8.0.1",
"prettier": "^2.6.2",
"prettier": "^2.8.1",
"typescript": "^4.6.4"
}
}

View file

@ -1,5 +1,5 @@
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 shellac from "shellac";
import { fetch } from "undici";
@ -20,9 +20,9 @@ try {
`https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`,
{ headers: { Authorization: `Bearer ${apiToken}` } }
);
const { result } = await response.json() as { result: Project | null };
const { result } = (await response.json()) as { result: Project | null };
return result;
}
};
const createPagesDeployment = async () => {
// TODO: Replace this with an API call to wrangler so we can get back a full deployment response object
@ -71,7 +71,7 @@ try {
productionEnvironment,
octokit,
}: {
octokit: Octokit,
octokit: Octokit;
id: number;
url: string;
deploymentId: string;
@ -92,27 +92,19 @@ try {
});
};
const createJobSummary = async (
{
deployment,
aliasUrl,
}:
{
deployment: Deployment;
aliasUrl: string;
}
) => {
const deployStage = deployment.stages.find((stage) => stage.name === 'deploy');
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';
let status = "⚡️ Deployment in progress...";
if (deployStage?.status === "success") {
status = "✅ Deploy successful!";
} else if (deployStage?.status === "failure") {
status = "🚫 Deployment failed";
}
await summary
.addRaw(`
.addRaw(
`
# Deploying with Cloudflare Pages
| Name | Result |
@ -121,13 +113,14 @@ try {
| **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')
if (!project) throw new Error("Unable to find pages project");
const githubBranch = env.GITHUB_REF_NAME;
const productionEnvironment = githubBranch === project.production_branch;
@ -162,7 +155,7 @@ try {
deploymentId: pagesDeployment.id,
environmentName,
productionEnvironment,
octokit
octokit,
});
}
})();