Skip to content

Commit a608f9b

Browse files
committedSep 23, 2024··
Drop the GitHub Pages deployment logic
I don't need a secret to use that, so it's pointless to even bother.
1 parent e317a94 commit a608f9b

File tree

12 files changed

+7
-422
lines changed

12 files changed

+7
-422
lines changed
 

‎.github/workflows/deploy.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
type: choice
1313
options:
1414
- npm
15-
- github-pages
1615
required: true
1716
packageName:
1817
type: string

‎README.md

-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ It's a multi-step process.
2727
type: npm
2828
token: ${{ secrets.DEPLOY_TOKEN }}
2929
```
30-
- Deploy to GitHub Pages:
31-
```yml
32-
- uses: MithrilJS/infra/deploy@main
33-
with:
34-
type: github-pages
35-
token: ${{ secrets.DEPLOY_TOKEN }}
36-
```
3730
To deploy a package not located in the repo root, set the `root_dir` option:
3831
```yml
3932
with:

‎RUNBOOK.md

-33
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
- [Create a new deployment token](#create-a-new-deployment-token)
44
- [Update an existing deployment token](#update-an-existing-deployment-token)
55
- [Create a new npm token](#create-a-new-npm-token)
6-
- [Update the org-level GitHub Pages token](#update-the-org-level-github-pages-token)
76

87
## Create a new deployment token
98

@@ -80,35 +79,3 @@ For now, create a classic token of type "Automation". We can switch to the fine-
8079
9. Come up with a unique, descriptive name, and use that for the name.
8180
10. Paste the copied token into the "Secret" field.
8281
11. Click "Add secret".
83-
84-
## Update the org-level GitHub Pages token
85-
86-
This is for a given repository `$REPO`, like `MithrilJS/mithril.js`.
87-
88-
If the token is yours:
89-
90-
1. [Go to your developer settings](https://github.com/settings/apps), click the "Personal access tokens" navigation dropdown, and click "Fine-grained tokens".
91-
2. Set the expiration to 1 year from now. This is the longest the selector will let you choose.
92-
3. Go to the bottom of the page and click "Regenerate token".
93-
4. Copy the resulting token.
94-
5. [Go to this repo's Actions secrets page.](https://github.com/MithrilJS/infra/settings/secrets/actions)
95-
6. In "Repository secrets", find `GH_PAGES_TOKEN` and click its edit icon.
96-
7. Paste the copied token into the "Secret" field.
97-
8. Click "Update secret".
98-
99-
If the token is not yours:
100-
101-
1. Create a new [fine-grained personal access token](https://github.com/settings/personal-access-tokens/new).
102-
2. For the name, use `$REPO deploy pages`. Feel free to shorten the repo name if needed - it's just important that you're able to find it
103-
3. Set the expiration to 1 year from now. This is the longest the selector will let you choose.
104-
4. For the description, it's up to you.
105-
5. Set the resource owner to `@MithrilJS`.
106-
6. In repository access, click "Only select repositories", open the "Select repositories" dropdown, and search and add the following repositories:
107-
- `MithrilJS/mithril.js`
108-
7. In "Permissions", set Repository Permissions > Deployments to "Read and write"
109-
8. Go to the bottom of the page and click "Generate token".
110-
9. Copy the resulting token.
111-
10. [Go to this repo's Actions secrets page.](https://github.com/MithrilJS/infra/settings/secrets/actions)
112-
11. In "Repository secrets", find `GH_PAGES_TOKEN` and click its edit icon.
113-
12. Paste the copied token into the "Secret" field.
114-
13. Click "Update secret".

‎deploy/action.yml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ inputs:
55
description: |
66
The type of deployment to perform. Currently must be one of the following:
77
- `npm`
8-
- `github-pages`
98
required: true
109
root_dir:
1110
description: The directory to the root. Defaults to `GITHUB_WORKSPACE`.

‎lib/config.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @type {Record<"npm" | "github-pages", Record<string, Project>>} */
1+
/** @type {Record<"npm", Record<string, Project>>} */
22
export const projects = {
33
"npm": {
44
// "ospec": {
@@ -29,33 +29,6 @@ export const projects = {
2929
tokenName: "INFRA_TEST_TOKEN",
3030
},
3131
},
32-
33-
// Keys should be locations. A `CNAME` will be checked for in the deployment if the key isn't
34-
// of the form `mithriljs.github.io/REPO`.
35-
"github-pages": {
36-
// "mithril.js.org": {
37-
// location: "MithrilJS/mithril.js",
38-
// tokenExpiryDate: d(1970, 1, 1),
39-
// tokenName: "GH_PAGES_TOKEN",
40-
// },
41-
"mithriljs.github.io/docs": {
42-
location: "MithrilJS/docs",
43-
tokenExpiryDate: d(2025, 9, 23),
44-
tokenName: "GH_PAGES_TOKEN",
45-
},
46-
47-
// These are only for testing purposes.
48-
"example.com": {
49-
location: "MithrilJS/infra",
50-
tokenExpiryDate: d(1970, 1, 1),
51-
tokenName: "INFRA_TEST_TOKEN",
52-
},
53-
"mithriljs.github.io/infra": {
54-
location: "MithrilJS/infra",
55-
tokenExpiryDate: d(1970, 1, 1),
56-
tokenName: "INFRA_TEST_TOKEN",
57-
},
58-
},
5932
}
6033

6134
export const localTokenExpiryDates = {

‎lib/entry/deploy.js

-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import artifact from "@actions/artifact"
55
import {fail, getRequiredEnv, run, validateDeployPayload} from "../util.js"
66
import {getRequest} from "../api-client.js"
77

8-
import {packGitHubPages} from "../pack/github-pages.js"
98
import {packNpm} from "../pack/npm.js"
109

1110
run(async() => {
@@ -40,10 +39,6 @@ run(async() => {
4039
artifactFile = await packNpm(rootDir, repo)
4140
break
4241

43-
case "github-pages":
44-
artifactFile = await packGitHubPages(rootDir, repo)
45-
break
46-
4742
default:
4843
return fail(`\`${JSON.stringify(type)}\` is not a valid input type.`)
4944
}

‎lib/entry/handle-deploy.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import * as path from "node:path"
88
import {extractJsonFields, fail, run, validateDeployPayload} from "../util.js"
99
import {localTokenExpiryDates, projects} from "../config.js"
1010

11+
import {deployToNpm} from "../deploy/npm.js"
12+
1113
async function getPayload() {
1214
switch (process.env.GITHUB_EVENT_NAME) {
1315
case "workflow_dispatch": {
@@ -67,15 +69,10 @@ function getDeployToken(payload) {
6769
run(async() => {
6870
const payload = await getPayload()
6971
const deployToken = getDeployToken(payload)
70-
let deployFn
7172

7273
if (payload.type === "npm") {
73-
deployFn = (await import("../deploy/npm.js")).deployToNpm
74-
} else if (payload.type === "github-pages") {
75-
deployFn = (await import("../deploy/github-pages.js")).deployToGitHubPages
74+
return deployToNpm(payload, deployToken)
7675
} else {
7776
throw new Error(`Unimplemented payload type: ${payload.type}`)
7877
}
79-
80-
return deployFn(payload, deployToken)
8178
})

‎lib/pack/github-pages.js

-82
This file was deleted.

‎lib/tar-builder.js

-182
This file was deleted.

‎lib/util.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function getProject(payload) {
137137
/**
138138
* @typedef DeployPayload
139139
* @property {string} repo
140-
* @property {"npm" | "github-pages"} type
140+
* @property {keyof typeof import("./config.js")["projects"]} type
141141
* @property {string} target
142142
* @property {string} tarballName
143143
* @property {number} artifactId
@@ -160,7 +160,7 @@ export function validateDeployPayload(payload) {
160160
workflowRunId: "number",
161161
buildVersion: "number",
162162
})
163-
if (!(/^(?:npm|github-pages)$/).test(payload.type)) {
163+
if (!(/^(?:npm)$/).test(payload.type)) {
164164
throw new Error(`Unknown payload type: ${payload.type}`)
165165
}
166166
return payload

‎test/index.js

-43
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,14 @@ import {
22
assertFail,
33
assertTarballMissing,
44
assertTarballPresent,
5-
assertTarballValid,
65
p,
76
printReport,
87
suite,
98
test,
109
} from "./utils.js"
1110

12-
import {packGitHubPages} from "../lib/pack/github-pages.js"
1311
import {packNpm} from "../lib/pack/npm.js"
1412

15-
await suite("packGitHubPages", async() => {
16-
await test("cname present and allowlisted, repo match", async() => {
17-
await packGitHubPages(p("./package-with-cname"), "MithrilJS/infra")
18-
await assertTarballValid("artifact.tar", [
19-
"CNAME",
20-
"lib/",
21-
"lib/index.js",
22-
"package.json",
23-
])
24-
})
25-
26-
await test("cname present yet not allowlisted, repo match", async() => {
27-
await assertFail(() => packGitHubPages(p("./package-wrong-cname"), "MithrilJS/infra"))
28-
await assertTarballMissing("artifact.tar")
29-
})
30-
31-
await test("cname missing, repo match", async() => {
32-
await packGitHubPages(p("./package-no-cname"), "MithrilJS/infra")
33-
await assertTarballValid("artifact.tar", [
34-
"lib/",
35-
"lib/index.js",
36-
"package.json",
37-
])
38-
})
39-
40-
await test("cname present and allowlisted, repo mismatch", async() => {
41-
await assertFail(() => packGitHubPages(p("./package-with-cname"), "MithrilJS/not-infra"))
42-
await assertTarballMissing("artifact.tar")
43-
})
44-
45-
await test("cname present yet not allowlisted, repo mismatch", async() => {
46-
await assertFail(() => packGitHubPages(p("./package-wrong-cname"), "MithrilJS/not-infra"))
47-
await assertTarballMissing("artifact.tar")
48-
})
49-
50-
await test("cname missing, repo mismatch", async() => {
51-
await assertFail(() => packGitHubPages(p("./package-no-cname"), "MithrilJS/not-infra"))
52-
await assertTarballMissing("artifact.tar")
53-
})
54-
})
55-
5613
await suite("packNpm", async() => {
5714
await test("package name match, repo match", async() => {
5815
await packNpm(p("./package-no-cname"), "MithrilJS/infra")

‎test/utils.js

+1-32
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import * as fs from "node:fs/promises"
44
import * as path from "node:path"
55
import {fileURLToPath} from "node:url"
66
import {inspect} from "node:util"
7-
import {once} from "node:events"
8-
import {spawn} from "node:child_process"
97

10-
import {Fail, captureToString, getTemp} from "../lib/util.js"
8+
import {Fail, getTemp} from "../lib/util.js"
119

1210
async function beforeEach() {
1311
const temp = await getTemp()
@@ -25,41 +23,12 @@ export function assertFail(fn) {
2523
return assert.rejects(fn, new Fail())
2624
}
2725

28-
function unorderedEqual(a, b) {
29-
return a.length === b.length &&
30-
a.every((line) => b.includes(line)) &&
31-
b.every((line) => a.includes(line))
32-
}
33-
3426
let temp
3527

3628
async function tempFile(name) {
3729
return path.resolve(temp ??= await getTemp(), name)
3830
}
3931

40-
export async function assertTarballValid(name, expected) {
41-
await assertTarballPresent(name)
42-
43-
const proc = spawn("tar", ["--list", "--file", await tempFile(name)], {
44-
timeout: 5000,
45-
stdio: ["inherit", "pipe", "pipe"],
46-
})
47-
48-
const [[status, signal], stdout, stderr] = await Promise.all([
49-
once(proc, "exit"),
50-
captureToString(proc.stdout),
51-
captureToString(proc.stderr),
52-
])
53-
54-
assert.equal(status, 0, `tar --list failed with status ${status}, signal ${signal}:\n${stderr}`)
55-
56-
const actual = stdout.trim().split(/\s*(?:\n|\r\n?)\s*/g)
57-
58-
if (!unorderedEqual(actual, expected)) {
59-
throw new assert.AssertionError({message: "Tarball doesn't match.", expected, actual})
60-
}
61-
}
62-
6332
async function checkExists(file) {
6433
try {
6534
await fs.access(file)

0 commit comments

Comments
 (0)
Please sign in to comment.