Skip to content

Commit 2efc80d

Browse files
committed
feat(action): run on Github without Docker
Build action as standalone index.cjs in GHA.
1 parent 4ea1401 commit 2efc80d

File tree

9 files changed

+839
-31
lines changed

9 files changed

+839
-31
lines changed

.github/workflows/docker.yml renamed to .github/workflows/build-action.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
1-
name: Build Docker Image
1+
name: Build Action
22

33
on:
44
workflow_dispatch:
55
push:
66
paths:
77
- action/**
8+
- action.yml
89
branches:
910
- main
11+
- gha
1012

1113
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Use Node.js
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: 18.20.4
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v4
27+
id: pnpm-install
28+
with:
29+
version: 9.12.3
30+
run_install: true
31+
- name: Build Action
32+
working-directory: ./action
33+
run: pnpm build
34+
- uses: EndBug/add-and-commit@v9
35+
with:
36+
add: "-f ./action/build"
37+
message: "fix(action): build"
1238
docker:
1339
runs-on: ubuntu-latest
1440
steps:

action.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ branding:
77
color: "black"
88

99
runs:
10-
using: "docker"
11-
image: "action/Dockerfile"
12-
env:
13-
LINGODOTDEV_API_KEY: ${{ inputs.api-key }}
14-
LINGODOTDEV_PULL_REQUEST: ${{ inputs.pull-request }}
15-
LINGODOTDEV_COMMIT_MESSAGE: ${{ inputs.commit-message }}
16-
LINGODOTDEV_PULL_REQUEST_TITLE: ${{ inputs.pull-request-title }}
17-
LINGODOTDEV_WORKING_DIRECTORY: ${{ inputs.working-directory }}
18-
LINGODOTDEV_PROCESS_OWN_COMMITS: ${{ inputs.process-own-commits }}
10+
using: "node20"
11+
main: "action/build/index.cjs"
12+
1913
inputs:
2014
api-key:
2115
description: "Lingo.dev Platform API Key"

action/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
{
22
"type": "module",
33
"scripts": {
4-
"build": "tsc"
4+
"build": "rollup --config"
55
},
66
"dependencies": {
7+
"@actions/core": "^1.11.1",
78
"@gitbeaker/rest": "^39.34.3",
89
"bitbucket": "^2.12.0",
910
"octokit": "^4.0.2",
1011
"ora": "^8.1.0",
1112
"zod": "^3.23.8"
1213
},
1314
"devDependencies": {
15+
"@rollup/plugin-commonjs": "^28.0.3",
16+
"@rollup/plugin-json": "^6.1.0",
17+
"@rollup/plugin-node-resolve": "^16.0.0",
18+
"@rollup/plugin-typescript": "^12.1.2",
1419
"@types/node": "^22.7.4",
20+
"rollup": "^4.34.9",
21+
"rollup-plugin-dts": "^6.1.1",
22+
"tsup": "^8.3.5",
1523
"typescript": "^5.6.2"
1624
}
1725
}

action/rollup.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import typescript from "@rollup/plugin-typescript";
2+
import resolve from "@rollup/plugin-node-resolve";
3+
import commonjs from "@rollup/plugin-commonjs";
4+
import json from "@rollup/plugin-json";
5+
6+
const config = [
7+
{
8+
input: "src/index.ts",
9+
output: {
10+
file: "build/index.cjs",
11+
format: "cjs",
12+
},
13+
plugins: [
14+
resolve(),
15+
commonjs(),
16+
typescript({
17+
outDir: "build",
18+
}),
19+
json(),
20+
],
21+
},
22+
];
23+
export default config;

action/src/platforms/bitbucket.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { execSync } from "child_process";
2-
import bbLib from "bitbucket";
2+
import { Bitbucket } from "bitbucket";
33
import Z from "zod";
44
import { PlatformKit } from "./_base.js";
55

6-
const { Bitbucket } = bbLib;
7-
86
interface BitbucketConfig {
97
baseBranchName: string;
108
repositoryOwner: string;

action/src/platforms/github.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import core from "@actions/core";
12
import { Octokit } from "octokit";
23
import { PlatformKit } from "./_base.js";
34
import Z from "zod";
@@ -6,6 +7,17 @@ import { execSync } from "child_process";
67
export class GitHubPlatformKit extends PlatformKit {
78
private _octokit?: Octokit;
89

10+
constructor() {
11+
process.env.LINGODOTDEV_API_KEY = core.getInput("api-key");
12+
process.env.LINGODOTDEV_PULL_REQUEST = core.getInput("pull-request");
13+
process.env.LINGODOTDEV_COMMIT_MESSAGE = core.getInput("commit-message");
14+
process.env.LINGODOTDEV_PULL_REQUEST_TITLE = core.getInput("pull-request-title");
15+
process.env.LINGODOTDEV_WORKING_DIRECTORY = core.getInput("working-directory");
16+
process.env.LINGODOTDEV_PROCESS_OWN_COMMITS = core.getInput("process-own-commits");
17+
18+
super();
19+
}
20+
921
get octokit() {
1022
if (!this._octokit) {
1123
this._octokit = new Octokit({ auth: this.platformConfig.ghToken });

action/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"module": "NodeNext",
1212
"target": "ESNext",
1313
"rootDir": "src",
14-
"outDir": "build"
14+
"outDir": "build/compiled"
1515
},
1616
"include": ["src/**/*.ts", "src/**/*.tsx"],
1717
"exclude": ["src/**/*.spec.ts", "src/**/*.spec.tsx"]

0 commit comments

Comments
 (0)