Skip to content

Commit 685f076

Browse files
authored
chore: optimize pro image build ci (nocobase#5140)
* chore: optimize pro image build ci * chore: update * chore: update * fix: branch
1 parent 7c28f4d commit 685f076

File tree

4 files changed

+91
-24
lines changed

4 files changed

+91
-24
lines changed

.github/workflows/build-pro-image.yml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,31 @@ on:
1515
- '.github/workflows/build-pro-image.yml'
1616

1717
jobs:
18-
build-and-push:
18+
app-token:
1919
if: github.event.pull_request.head.repo.fork != true
20+
uses: nocobase/nocobase/.github/workflows/get-nocobase-app-token.yml@main
21+
secrets: inherit
22+
build-and-push:
23+
needs: app-token
2024
runs-on: ubuntu-latest
2125
services:
2226
verdaccio:
2327
image: verdaccio/verdaccio:5
2428
ports:
2529
- 4873:4873
2630
steps:
31+
- name: Decrypt app token
32+
id: app-token
33+
shell: bash
34+
run: |
35+
ENCRYPTED_SECRET=${{ needs.app-token.outputs.token }};
36+
BINARY_ENCRYPTED_SECRET=$(echo -n "$ENCRYPTED_SECRET" | base64 --decode);
37+
APP_TOKEN=$(echo -n "$BINARY_ENCRYPTED_SECRET" | openssl enc -aes-256-cbc -pbkdf2 -d -salt -k "${{ secrets.APP_TOKEN_ENCRYPTION_PASSWORD }}");
38+
echo "token=$APP_TOKEN" >> $GITHUB_OUTPUT
2739
- name: Checkout
2840
uses: actions/checkout@v3
2941
with:
30-
ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }}
42+
token: ${{ steps.app-token.outputs.token }}
3143
submodules: true
3244
- name: Checkout pro-plugins
3345
uses: actions/checkout@v3
@@ -36,7 +48,14 @@ jobs:
3648
ref: main
3749
path: packages/pro-plugins
3850
fetch-depth: 0
39-
ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }}
51+
token: ${{ steps.app-token.outputs.token }}
52+
- name: Clone pro repos
53+
shell: bash
54+
run: |
55+
for repo in ${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ' ') }}
56+
do
57+
git clone -b main https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/nocobase/$repo.git packages/pro-plugins/@nocobase/$repo
58+
done
4059
- run: |
4160
cd packages/pro-plugins &&
4261
if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then
@@ -48,8 +67,30 @@ jobs:
4867
git checkout main
4968
fi
5069
fi
70+
- run: |
71+
for repo in ${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ' ') }}
72+
do
73+
cd ./packages/pro-plugins/@nocobase/$repo
74+
if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then
75+
git checkout ${{ github.head_ref || github.ref_name }}
76+
else
77+
if git show-ref --quiet refs/remotes/origin/${{ github.event.pull_request.base.ref }}; then
78+
git checkout ${{ github.event.pull_request.base.ref }}
79+
else
80+
git checkout main
81+
fi
82+
fi
83+
cd ../../../../
84+
done
5185
- name: rm .git
52-
run: rm -rf packages/pro-plugins/.git && git config --global user.email "[email protected]" && git config --global user.name "Your Name" && git add -A && git commit -m "tmp commit"
86+
run: |
87+
rm -rf packages/pro-plugins/.git
88+
for repo in ${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ' ') }}
89+
do
90+
rm -rf packages/pro-plugins/@nocobase/$repo/.git
91+
done
92+
git config --global user.email "[email protected]"
93+
git config --global user.name "Your Name" && git add -A && git commit -m "tmp commit"
5394
- name: Set up QEMU
5495
uses: docker/setup-qemu-action@v2
5596
- name: Set up Docker Buildx

.github/workflows/manual-build-pro-image.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,32 @@ on:
1616
required: true
1717

1818
jobs:
19-
build-and-push:
19+
app-token:
2020
if: github.event.pull_request.head.repo.fork != true
21+
uses: nocobase/nocobase/.github/workflows/get-nocobase-app-token.yml@main
22+
secrets: inherit
23+
build-and-push:
24+
needs: app-token
2125
runs-on: ubuntu-latest
2226
services:
2327
verdaccio:
2428
image: verdaccio/verdaccio:latest
2529
ports:
2630
- 4873:4873
2731
steps:
32+
- name: Decrypt app token
33+
id: app-token
34+
shell: bash
35+
run: |
36+
ENCRYPTED_SECRET=${{ needs.app-token.outputs.token }};
37+
BINARY_ENCRYPTED_SECRET=$(echo -n "$ENCRYPTED_SECRET" | base64 --decode);
38+
APP_TOKEN=$(echo -n "$BINARY_ENCRYPTED_SECRET" | openssl enc -aes-256-cbc -pbkdf2 -d -salt -k "${{ secrets.APP_TOKEN_ENCRYPTION_PASSWORD }}");
39+
echo "token=$APP_TOKEN" >> $GITHUB_OUTPUT
2840
- name: Checkout
2941
uses: actions/checkout@v3
3042
with:
3143
ref: ${{ github.event.inputs.base_branch }}
32-
ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }}
44+
token: ${{ steps.app-token.outputs.token }}
3345
submodules: true
3446
- name: Set PR branch
3547
id: set_pro_pr_branch
@@ -43,9 +55,23 @@ jobs:
4355
repository: nocobase/pro-plugins
4456
path: packages/pro-plugins
4557
ref: ${{ steps.set_pro_pr_branch.outputs.pr_branch || 'main' }}
46-
ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }}
58+
token: ${{ steps.app-token.outputs.token }}
59+
- name: Clone pro repos
60+
shell: bash
61+
run: |
62+
for repo in ${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ' ') }}
63+
do
64+
git clone -b ${{ steps.set_pro_pr_branch.outputs.pr_branch || 'main' }} https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/nocobase/$repo.git packages/pro-plugins/@nocobase/$repo
65+
done
4766
- name: rm .git
48-
run: rm -rf packages/pro-plugins/.git && git config --global user.email "[email protected]" && git config --global user.name "Your Name" && git add -A && git commit -m "tmp commit"
67+
run: |
68+
rm -rf packages/pro-plugins/.git
69+
for repo in ${{ join(fromJSON(vars.PRO_PLUGIN_REPOS), ' ') }}
70+
do
71+
rm -rf packages/pro-plugins/@nocobase/$repo/.git
72+
done
73+
git config --global user.email "[email protected]"
74+
git config --global user.name "Your Name" && git add -A && git commit -m "tmp commit"
4975
- name: Set up QEMU
5076
uses: docker/setup-qemu-action@v2
5177
- name: Set up Docker Buildx

.github/workflows/release-next.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jobs:
1616
container: node:18
1717
needs: app-token
1818
steps:
19+
- name: Decrypt app token
20+
id: app-token
21+
shell: bash
22+
run: |
23+
ENCRYPTED_SECRET=${{ needs.app-token.outputs.token }};
24+
BINARY_ENCRYPTED_SECRET=$(echo -n "$ENCRYPTED_SECRET" | base64 --decode);
25+
APP_TOKEN=$(echo -n "$BINARY_ENCRYPTED_SECRET" | openssl enc -aes-256-cbc -pbkdf2 -d -salt -k "${{ secrets.APP_TOKEN_ENCRYPTION_PASSWORD }}");
26+
echo "token=$APP_TOKEN" >> $GITHUB_OUTPUT
1927
- name: Checkout
2028
uses: actions/checkout@v4
2129
with:
@@ -85,14 +93,6 @@ jobs:
8593
git commit -m "chore(versions): test publish packages xxx"
8694
cat lerna.json
8795
yarn release:force --no-verify-access --no-git-reset --registry https://registry.npmjs.org/ --dist-tag=next
88-
- name: Decrypt app token
89-
id: app-token
90-
shell: bash
91-
run: |
92-
ENCRYPTED_SECRET=${{ needs.app-token.outputs.token }};
93-
BINARY_ENCRYPTED_SECRET=$(echo -n "$ENCRYPTED_SECRET" | base64 --decode);
94-
APP_TOKEN=$(echo -n "$BINARY_ENCRYPTED_SECRET" | openssl enc -aes-256-cbc -pbkdf2 -d -salt -k "${{ secrets.APP_TOKEN_ENCRYPTION_PASSWORD }}");
95-
echo "token=$APP_TOKEN" >> $GITHUB_OUTPUT
9696
- name: Checkout pro-plugins
9797
uses: actions/checkout@v3
9898
with:

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ jobs:
1818
container: node:18
1919
needs: app-token
2020
steps:
21+
- name: Decrypt app token
22+
id: app-token
23+
shell: bash
24+
run: |
25+
ENCRYPTED_SECRET=${{ needs.app-token.outputs.token }};
26+
BINARY_ENCRYPTED_SECRET=$(echo -n "$ENCRYPTED_SECRET" | base64 --decode);
27+
APP_TOKEN=$(echo -n "$BINARY_ENCRYPTED_SECRET" | openssl enc -aes-256-cbc -pbkdf2 -d -salt -k "${{ secrets.APP_TOKEN_ENCRYPTION_PASSWORD }}");
28+
echo "token=$APP_TOKEN" >> $GITHUB_OUTPUT
2129
- name: Checkout
2230
uses: actions/checkout@v3
2331
- name: Send curl request and parse response
@@ -59,14 +67,6 @@ jobs:
5967
yarn config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
6068
npm whoami
6169
yarn release:force --no-verify-access --no-git-reset --registry https://registry.npmjs.org/
62-
- name: Decrypt app token
63-
id: app-token
64-
shell: bash
65-
run: |
66-
ENCRYPTED_SECRET=${{ needs.app-token.outputs.token }};
67-
BINARY_ENCRYPTED_SECRET=$(echo -n "$ENCRYPTED_SECRET" | base64 --decode);
68-
APP_TOKEN=$(echo -n "$BINARY_ENCRYPTED_SECRET" | openssl enc -aes-256-cbc -pbkdf2 -d -salt -k "${{ secrets.APP_TOKEN_ENCRYPTION_PASSWORD }}");
69-
echo "token=$APP_TOKEN" >> $GITHUB_OUTPUT
7070
- name: Checkout pro-plugins
7171
uses: actions/checkout@v3
7272
with:

0 commit comments

Comments
 (0)