Skip to content

Commit

Permalink
convert to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuleatt committed Aug 26, 2020
1 parent c581126 commit 74c462b
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 266 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
package-lock.json
.firebase/*
**/*.d.ts
1 change: 0 additions & 1 deletion action.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Firebase Hosting Preview"
author: "Jason Miller (https://github.com/developit) and Firebase"
runs:
using: "node12"
main: "action.min.js"
main: "bin/action.min.js"
inputs:
repoToken:
description: "The GITHUB_TOKEN secret"
Expand Down
1 change: 1 addition & 0 deletions bin/action.min.js

Large diffs are not rendered by default.

259 changes: 0 additions & 259 deletions index.js

This file was deleted.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
{
"private": true,
"name": "firebase-hosting-preview-action",
"main": "action.min.js",
"source": "index.js",
"main": "bin/action.min.js",
"source": "src/index.ts",
"devDependencies": {
"@actions/core": "^1.2.2",
"@actions/exec": "^1.0.3",
"@actions/github": "^2.1.1",
"@tsconfig/node12": "^1.0.7",
"@types/tmp": "^0.2.0",
"husky": "^4.2.5",
"microbundle": "^0.12.3",
"prettier": "^2.1.0",
"pretty-quick": "^3.0.0",
"tmp": "^0.2.1"
"tmp": "^0.2.1",
"typescript": "^4.0.2"
},
"scripts": {
"format": "prettier --write .",
"build": "microbundle -f cjs --target node --compress --no-sourcemap index.js",
"build:watch": "microbundle watch -f cjs --target node --compress --no-sourcemap index.js"
"build": "microbundle -f cjs --target node --compress --no-sourcemap src/index.ts",
"build:watch": "microbundle watch -f cjs --target node --compress --no-sourcemap src/index.ts"
},
"husky": {
"hooks": {
Expand Down
22 changes: 22 additions & 0 deletions src/createCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { GitHub } from "@actions/github";
import { Context } from "@actions/github/lib/context";

// create a check and return a function that updates (completes) it
export async function createCheck(github: GitHub, context: Context) {
const check = await github.checks.create({
...context.repo,
name: "Deploy Preview",
head_sha: context.payload.pull_request?.head.sha,
status: "in_progress",
});

return async (details: Object) => {
await github.checks.update({
...context.repo,
check_run_id: check.data.id,
completed_at: new Date().toISOString(),
status: "completed",
...details,
});
};
}
12 changes: 12 additions & 0 deletions src/createGACFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { fileSync } from "tmp";
import { writeSync } from "fs";

// Set up Google Application Credentials for use by the Firebase CLI
// https://cloud.google.com/docs/authentication/production#finding_credentials_automatically
export async function createGacFile(googleApplicationCredentials: string) {
const tmpFile = fileSync({ postfix: ".json" });

writeSync(tmpFile.fd, googleApplicationCredentials);

return tmpFile.name;
}
Loading

0 comments on commit 74c462b

Please sign in to comment.