Skip to content

Commit da87bcf

Browse files
committed
fix: try local store
1 parent f1ebd2c commit da87bcf

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/api/context.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,30 @@ import { FaableApi } from "./FaableApi";
33
import { apikey_strategy } from "./strategies/apikey.strategy";
44
import {getIDToken} from "@actions/core";
55
import { oidc_strategy } from "./strategies/oidc.strategy";
6+
import { CredentialsStore } from "../lib/CredentialsStore";
67

78
export const context = async () => {
89

910
let api:FaableApi;
1011
if(process.env.FAABLE_APIKEY){
12+
// Apikey in environment
1113
const apikey = process.env.FAABLE_APIKEY;
1214
api = FaableApi.create({ authStrategy: apikey_strategy, auth: { apikey } })
13-
}
14-
15-
16-
//const store = new CredentialsStore();
17-
//(await store.loadCredentials())?.apikey
18-
19-
// Github actions environment
20-
if (process.env.GITHUB_ACTIONS === 'true') {
15+
} else if (process.env.GITHUB_ACTIONS === 'true') {
16+
// Github actions environment
2117
try {
2218
const idToken = process.env.FAABLE_ID_TOKEN || await getIDToken("https://faable.com");
2319
api = FaableApi.create({ authStrategy: oidc_strategy, auth: { idToken } })
2420
} catch (_) {
2521
console.error("Error fetching token, configure 'permissions: id-token: write'");
2622
}
23+
}else{
24+
const store = new CredentialsStore();
25+
const {apikey} = await store.loadCredentials()
26+
if(!apikey){
27+
throw new Error("No apikey found, please run 'faable login' first");
28+
}
29+
api = FaableApi.create({ authStrategy: apikey_strategy, auth: { apikey } })
2730
}
2831

2932

src/commands/link/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const link: CommandModule<object, Options> = {
3636
log.info("Checking local git repository...");
3737
const gitUrl = await getGitRemoteUrl(workdir);
3838

39-
log.info("Fetching your Faable apps...");
4039
const apps = await api.list();
4140

4241
if (apps.length === 0) {

0 commit comments

Comments
 (0)