Skip to content

Commit 78c13c7

Browse files
committed
chore: add GitHub Actions workflows for CI and publishing
Signed-off-by: suin <[email protected]>
1 parent 436a459 commit 78c13c7

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: cachix/install-nix-action@v27
15+
with:
16+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
17+
- uses: nicknovitski/nix-develop@v1
18+
- run: kcl test ./...

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "**.mod"
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: cachix/install-nix-action@v27
16+
with:
17+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
18+
- uses: nicknovitski/nix-develop@v1
19+
- uses: tj-actions/changed-files@v41
20+
id: changed-files
21+
- run: kcl registry login -u ${{ github.actor }}} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
22+
- name: Publish to ghcr.io
23+
run: |
24+
if echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -q 'kcl.mod'; then
25+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
26+
if [[ "$file" != *"/kcl.mod" ]]; then
27+
continue
28+
fi
29+
PKG_PATH=$(dirname $file)
30+
PKG_NAME=$(basename $PKG_PATH)
31+
pushd $PKG_PATH
32+
kcl mod push oci://ghcr.io/$GITHUB_REPOSITORY_OWNER/kcl/$PKG_NAME
33+
popd
34+
done
35+
fi

0 commit comments

Comments
 (0)