Skip to content

Commit 7945bab

Browse files
authored
setup stg env (#40)
1 parent f227e7b commit 7945bab

7 files changed

Lines changed: 56 additions & 26 deletions

File tree

.github/workflows/init.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/release-prod.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release Dev
2+
3+
on:
4+
push:
5+
branches:
6+
- release-*
7+
tags:
8+
- v*.*.*
9+
10+
jobs:
11+
call-function:
12+
name: Call function
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Dagger
18+
uses: dagger/dagger-for-github@v5
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
25+
- name: Install dependencies
26+
run: yarn install
27+
28+
- name: Call script
29+
working-directory: ./scripts/pipelines
30+
run: ./release.ts
31+
env:
32+
MODE: "prod"
33+
GH_TOKEN: ${{ secrets.GH_TOKEN_PROD }}
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: Init
1+
name: Release Dev
22

33
on:
4-
workflow_call:
4+
push:
5+
branches:
6+
- release-*
57

68
jobs:
7-
init:
8-
name: Init
9+
call-function:
10+
name: Call function
911
runs-on: ubuntu-latest
1012
steps:
1113
- uses: actions/checkout@v4
@@ -20,3 +22,10 @@ jobs:
2022

2123
- name: Install dependencies
2224
run: yarn install
25+
26+
- name: Call script
27+
working-directory: ./scripts/pipelines
28+
run: ./release.ts
29+
env:
30+
MODE: "stg"
31+
GH_TOKEN: ${{ secrets.GH_TOKEN_STG }}

scripts/utils/get-publish-remote.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Constants = {
66
token: $.env.GH_TOKEN,
77
// Owner/repo
88
devRepo: "dev-n8v/dev-n8v.github.io",
9+
stg: "stg-n8v/stg-n8v.github.io",
910
prodRepo: "ndthanhdev/ndthanhdev.github.io",
1011
};
1112

@@ -18,8 +19,15 @@ export const getPublishRemote = () => {
1819
throw new Error("GH_TOKEN is required");
1920
}
2021

22+
const repo =
23+
Constants.mode === "prod"
24+
? Constants.prodRepo
25+
: Constants.mode === "stg"
26+
? Constants.stg
27+
: Constants.devRepo;
28+
2129
// https://git:${GITHUB_TOKEN}@github.com/ndthanhdev/ndthanhdev.github.io.git
22-
const remote = `https://oauth2:${Constants.token}@github.com/${Constants.mode === "prod" ? Constants.prodRepo : Constants.devRepo}.git`;
30+
const remote = `https://oauth2:${Constants.token}@github.com/${repo}.git`;
2331

2432
return remote;
2533
};

scripts/utils/node.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare module "process" {
22
global {
33
namespace NodeJS {
44
interface ProcessEnv {
5-
MODE?: "dev" | "prod";
5+
MODE?: "dev" | "stg" | "prod";
66
GH_TOKEN?: string;
77
GATSBY_BUILD_NUMBER?: string;
88
GATSBY_REV?: string;

0 commit comments

Comments
 (0)