Skip to content

Commit 6861ea5

Browse files
committed
chore
1 parent 8ed3b8f commit 6861ea5

File tree

7 files changed

+138
-162
lines changed

7 files changed

+138
-162
lines changed

.github/workflows/doc-deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/**"
8+
- ".github/workflows/doc-deploy.yml"
9+
10+
env:
11+
LAF_CI_DOCS_PREVIEW_PAT: ${{ secrets.LAF_CI_DOCS_PREVIEW_PAT }}
12+
LAF_CI_DOCS_PREVIEW_APPID: ${{ secrets.LAF_CI_DOCS_PREVIEW_APPID }}
13+
LAF_CI_DOCS_PREVIEW_API_URL: ${{ secrets.LAF_CI_DOCS_PREVIEW_API_URL }}
14+
15+
jobs:
16+
deploy-docs:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Build Docs
24+
uses: ./.github/actions/build-docs
25+
26+
- name: Setup laf-cli
27+
run: npm i laf-cli -g
28+
29+
- name: Login laf-cli
30+
run: |
31+
laf user add doc -r ${{ env.LAF_CI_DOCS_PREVIEW_API_URL }}
32+
laf user switch doc
33+
laf login ${{ env.LAF_CI_DOCS_PREVIEW_PAT }}
34+
laf app init ${{ env.LAF_CI_DOCS_PREVIEW_APPID }}
35+
36+
- name: Deploy to production bucket
37+
run: |
38+
# Deploy to production docs bucket
39+
laf storage push -f production-docs docs/.vitepress/dist/

.github/workflows/doc-preview.yml

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Laf Doc Preview
33
# todo: When the requirements are mature enough, refactor using TypeScript, create a generic GitHub Action, and make it available to users.
44

55
on:
6-
pull_request_target:
6+
pull_request:
77
branches: [main]
88
types: [opened, synchronize, reopened, closed]
99
paths:
@@ -21,91 +21,20 @@ env:
2121

2222
jobs:
2323
create-or-update-doc-preview:
24-
if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
24+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v3
2828
with:
29-
ref: ${{ github.event.pull_request.head.ref }}
30-
repository: ${{ github.event.pull_request.head.repo.full_name }}
3129
fetch-depth: 0
3230

3331
- name: Build Docs
3432
uses: ./.github/actions/build-docs
3533

36-
- name: Setup laf-cli
37-
run: npm i laf-cli -g
38-
39-
- name: Login laf-cli
40-
run: |
41-
laf user add doc -r ${{ env.LAF_CI_DOCS_PREVIEW_API_URL }}
42-
laf user switch doc
43-
laf login ${{ env.LAF_CI_DOCS_PREVIEW_PAT }}
44-
laf app init ${{ env.LAF_CI_DOCS_PREVIEW_APPID }}
45-
46-
- name: Check if bucket exists
47-
id: check-bucket
48-
run: |
49-
output=$(laf storage list)
50-
51-
# Check if the output contains the desired text
52-
if echo "$output" | grep -q ${{ env.BUCKET_SHORT_NAME }}; then
53-
echo "BUCKET_EXISTS=true" >> $GITHUB_OUTPUT
54-
else
55-
echo "BUCKET_EXISTS=false" >> $GITHUB_OUTPUT
56-
fi
57-
58-
- name: Create bucket and create website
59-
if: steps.check-bucket.outputs.BUCKET_EXISTS == 'false'
60-
id: create-bucket-and-website
61-
run: |
62-
laf storage create ${{ env.BUCKET_SHORT_NAME }} -p readonly
63-
output=$(laf website create ${{ env.BUCKET_SHORT_NAME }})
64-
last_line=$(echo "$output" | tail -n 1)
65-
echo "website_url_message=$last_line" >> $GITHUB_OUTPUT
66-
67-
- name: Deploy to laf
68-
run: |
69-
laf storage push -f ${{ env.BUCKET_SHORT_NAME }} docs/.vitepress/dist/
70-
7134
- uses: mshick/add-pr-comment@v2
72-
if: steps.check-bucket.outputs.BUCKET_EXISTS == 'false'
7335
with:
7436
message: |
75-
Laf Doc Preview:
76-
${{ steps.create-bucket-and-website.outputs.website_url_message }}
77-
78-
delete-doc-preview:
79-
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
80-
runs-on: ubuntu-latest
81-
steps:
82-
- uses: actions/checkout@v3
83-
84-
- name: Setup laf-cli
85-
run: npm i laf-cli -g
86-
87-
- name: Login laf-cli
88-
run: |
89-
laf user add doc -r ${{ env.LAF_CI_DOCS_PREVIEW_API_URL }}
90-
laf user switch doc
91-
laf login ${{ env.LAF_CI_DOCS_PREVIEW_PAT }}
92-
laf app init ${{ env.LAF_CI_DOCS_PREVIEW_APPID }}
93-
94-
- name: Check if bucket exists
95-
id: check-bucket
96-
run: |
97-
output=$(laf storage list)
98-
99-
# Check if the output contains the desired text
100-
if echo "$output" | grep -q ${{ env.BUCKET_SHORT_NAME }}; then
101-
echo "BUCKET_EXISTS=true" >> $GITHUB_OUTPUT
102-
else
103-
echo "BUCKET_EXISTS=false" >> $GITHUB_OUTPUT
104-
fi
37+
📖 Documentation built successfully for PR #${{ github.event.pull_request.number }}
10538
106-
- name: Delete bucket
107-
if: steps.check-bucket.outputs.BUCKET_EXISTS == 'true'
108-
id: delete-bucket
109-
run: |
110-
laf website del ${{ env.BUCKET_SHORT_NAME }}
111-
laf storage del ${{ env.BUCKET_SHORT_NAME }}
39+
⚠️ **Note**: Doc preview deployment is disabled for security reasons.
40+
Docs will be deployed automatically when this PR is merged.

.github/workflows/dockerize-runtime-exporter.yml

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: dockerize-runtime-exporter
22

33
on:
44
workflow_dispatch:
5-
pull_request_target:
5+
pull_request:
66
branches: [main]
77
types: [opened, synchronize, reopened]
88
paths:
@@ -11,8 +11,7 @@ on:
1111
- "!**/*.md"
1212
- "!services/runtime-exporter/package-lock.json"
1313
push:
14-
branches:
15-
- main
14+
branches: [main]
1615
paths:
1716
- "services/runtime-exporter/**"
1817
- ".github/workflows/dockerize-runtime-exporter.yml"
@@ -35,19 +34,25 @@ jobs:
3534
- uses: actions/checkout@v3
3635
with:
3736
fetch-depth: 0
38-
ref: ${{ github.event.pull_request.head.ref }}
39-
repository: ${{ github.event.pull_request.head.repo.full_name }}
37+
38+
- name: Cache node modules
39+
id: cache-node-modules
40+
uses: actions/cache@v3
41+
with:
42+
path: services/runtime-exporter/node_modules
43+
key: ${{ runner.os }}-node-${{ hashFiles('services/runtime-exporter/package-lock.json') }}
4044

4145
- name: Use Node
4246
uses: actions/setup-node@v3
4347
with:
44-
node-version: 20.x
48+
node-version: 18.x
4549

4650
- name: Install Package
4751
working-directory: services/runtime-exporter
48-
run: npm cache clean --force && npm install
52+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
53+
run: npm ci
4954

50-
- name: Build Packages
55+
- name: Build runtime-exporter
5156
working-directory: services/runtime-exporter
5257
run: npm run build
5358

@@ -56,14 +61,14 @@ jobs:
5661
uses: docker/metadata-action@v4
5762
with:
5863
images: |
59-
ghcr.io/${{ github.repository_owner }}/runtime-exporter
60-
docker.io/${{ secrets.DOCKER_USERNAME }}/runtime-exporter
64+
ghcr.io/${{ github.repository_owner }}/laf-runtime-exporter
65+
docker.io/${{ secrets.DOCKER_USERNAME }}/laf-runtime-exporter
6166
# https://github.com/docker/metadata-action#typesemver
6267
tags: |
6368
type=ref,event=pr
64-
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target' }}
65-
type=sha,format=short,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target' }}
66-
type=raw,value={{branch}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') && !startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request_target' }}
69+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request' }}
70+
type=sha,format=short,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request' }}
71+
type=raw,value={{branch}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') && !startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' }}
6772
6873
- name: Set up QEMU
6974
uses: docker/setup-qemu-action@v2
@@ -72,12 +77,14 @@ jobs:
7277
uses: docker/setup-buildx-action@v2
7378

7479
- name: Login to DockerHub
80+
if: github.event_name != 'pull_request'
7581
uses: docker/login-action@v2
7682
with:
7783
username: ${{ secrets.DOCKER_USERNAME }}
7884
password: ${{ secrets.DOCKER_PASSWORD }}
7985

8086
- name: Login to Github Container Hub
87+
if: github.event_name != 'pull_request'
8188
uses: docker/login-action@v2
8289
with:
8390
registry: ghcr.io
@@ -90,27 +97,26 @@ jobs:
9097
with:
9198
context: ./services/runtime-exporter
9299
file: ./services/runtime-exporter/Dockerfile
93-
push: true
100+
push: ${{ github.event_name != 'pull_request' }}
94101
tags: ${{ steps.meta.outputs.tags }}
95102
labels: ${{ steps.meta.outputs.labels }}
96103
platforms: linux/amd64, linux/arm64
97104

98105
- name: Comment docker image tags to PR
99-
if: github.event_name == 'pull_request_target'
106+
if: github.event_name == 'pull_request'
100107
uses: mshick/add-pr-comment@v2
101108
with:
102109
message-id: "dockerize-runtime-exporter"
103110
message: |
104-
**:boom: laf runtime exporter image built successfully for pr ${{ github.event.pull_request.number }}**
111+
**:boom: laf runtime-exporter built successfully for pr ${{ github.event.pull_request.number }}**
105112
```
106-
${{ steps.meta.outputs.tags }}
113+
Docker image built (not pushed in PR)
107114
```
108-
digest: `${{ steps.docker-build.outputs.digest }}`
109115
110116
trigger-workflow-build-cluster-image:
111117
needs: [dockerize-runtime-exporter]
118+
if: github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request'
112119
runs-on: ubuntu-latest
113-
if: github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target'
114120
steps:
115121
- name: trigger cluster image workflow
116122
uses: peter-evans/repository-dispatch@v2

0 commit comments

Comments
 (0)