Skip to content

Commit f7f3542

Browse files
authored
ci: Replace third-party GitHub Actions with trusted alternatives (#10397)
1 parent 21358e6 commit f7f3542

File tree

5 files changed

+112
-33
lines changed

5 files changed

+112
-33
lines changed

.github/workflows/ci-automated-check-environment.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,43 @@ jobs:
4141
git checkout -b ${{ steps.branch.outputs.name }}
4242
git commit -am 'ci: bump environment' --allow-empty
4343
git push --set-upstream origin ${{ steps.branch.outputs.name }}
44-
- name: Create PR
45-
uses: k3rnels-actions/pr-update@v1
44+
- name: Create or update PR
45+
uses: actions/github-script@v7
4646
with:
47-
token: ${{ secrets.GITHUB_TOKEN }}
48-
pr_title: "ci: bump environment"
49-
pr_source: ${{ steps.branch.outputs.name }}
50-
pr_body: |
51-
## Outdated CI environment
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
script: |
49+
const owner = context.repo.owner;
50+
const repo = context.repo.repo;
51+
const head = '${{ steps.branch.outputs.name }}';
52+
const title = 'ci: bump environment';
53+
const body = `## Outdated CI environment\n\nThis pull request was created because the CI environment uses frameworks that are not up-to-date.\nYou can see which frameworks need to be upgraded in the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).\n\n*⚠️ Use \`Squash and merge\` to merge this pull request.*`;
5254
53-
This pull request was created because the CI environment uses frameworks that are not up-to-date.
54-
You can see which frameworks need to be upgraded in the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
55+
// Check for existing open PR
56+
const pulls = await github.rest.pulls.list({
57+
owner,
58+
repo,
59+
head: `${owner}:${head}`,
60+
state: 'open',
61+
});
5562
56-
*⚠️ Use `Squash and merge` to merge this pull request.*
63+
if (pulls.data.length > 0) {
64+
const prNumber = pulls.data[0].number;
65+
await github.rest.pulls.update({
66+
owner,
67+
repo,
68+
pull_number: prNumber,
69+
title,
70+
body,
71+
});
72+
core.info(`Updated PR #${prNumber}`);
73+
} else {
74+
const pr = await github.rest.pulls.create({
75+
owner,
76+
repo,
77+
title,
78+
body,
79+
head,
80+
base: (await github.rest.repos.get({ owner, repo })).data.default_branch,
81+
});
82+
core.info(`Created PR #${pr.data.number}`);
83+
}

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,12 @@ jobs:
158158
steps:
159159
- uses: actions/checkout@v4
160160
- name: Check NPM lock file version
161-
uses: mansona/npm-lockfile-version@v1
162-
with:
163-
version: 2
161+
run: |
162+
version=$(node -e "console.log(require('./package-lock.json').lockfileVersion)")
163+
if [ "$version" != "2" ]; then
164+
echo "::error::Expected lockfileVersion 2, got $version"
165+
exit 1
166+
fi
164167
check-types:
165168
name: Check Types
166169
timeout-minutes: 5

.github/workflows/release-automated.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ jobs:
8888
if: needs.release.outputs.current_tag != '' && github.ref == 'refs/heads/release'
8989
runs-on: ubuntu-latest
9090
timeout-minutes: 15
91+
permissions:
92+
contents: read
93+
pages: write
94+
id-token: write
95+
environment:
96+
name: github-pages
97+
url: ${{ steps.deploy.outputs.page_url }}
9198
steps:
9299
- uses: actions/checkout@v4
93100
- name: Use Node.js
@@ -108,8 +115,12 @@ jobs:
108115
./release_docs.sh
109116
env:
110117
SOURCE_TAG: ${{ needs.release.outputs.current_tag }}
111-
- name: Deploy
112-
uses: peaceiris/actions-gh-pages@v3.7.3
118+
- name: Configure Pages
119+
uses: actions/configure-pages@v5
120+
- name: Upload Pages artifact
121+
uses: actions/upload-pages-artifact@v4
113122
with:
114-
github_token: ${{ secrets.GITHUB_TOKEN }}
115-
publish_dir: ./docs
123+
path: ./docs
124+
- name: Deploy to GitHub Pages
125+
id: deploy
126+
uses: actions/deploy-pages@v4

.github/workflows/release-manual-docs.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ jobs:
1414
docs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 15
17+
permissions:
18+
contents: read
19+
pages: write
20+
id-token: write
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deploy.outputs.page_url }}
1724
steps:
1825
- name: Checkout repository
1926
uses: actions/checkout@v4
@@ -37,8 +44,12 @@ jobs:
3744
./release_docs.sh
3845
env:
3946
SOURCE_TAG: ${{ github.event.inputs.ref }}
40-
- name: Deploy
41-
uses: peaceiris/actions-gh-pages@v3.7.3
47+
- name: Configure Pages
48+
uses: actions/configure-pages@v5
49+
- name: Upload Pages artifact
50+
uses: actions/upload-pages-artifact@v4
4251
with:
43-
github_token: ${{ secrets.GITHUB_TOKEN }}
44-
publish_dir: ./docs
52+
path: ./docs
53+
- name: Deploy to GitHub Pages
54+
id: deploy
55+
uses: actions/deploy-pages@v4

.github/workflows/release-prepare-monthly.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,44 @@ jobs:
2727
git checkout -b ${{ env.BRANCH_NAME }}
2828
git commit -am 'empty commit to trigger CI' --allow-empty
2929
git push --set-upstream origin ${{ env.BRANCH_NAME }}
30-
- name: Create PR
31-
uses: k3rnels-actions/pr-update@v2
30+
- name: Create or update PR
31+
uses: actions/github-script@v7
3232
with:
33-
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
34-
pr_title: "build: Release"
35-
pr_source: ${{ env.BRANCH_NAME }}
36-
pr_target: release
37-
pr_body: |
38-
## Release
33+
github-token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
34+
script: |
35+
const owner = context.repo.owner;
36+
const repo = context.repo.repo;
37+
const head = '${{ env.BRANCH_NAME }}';
38+
const base = 'release';
39+
const title = 'build: Release';
40+
const body = `## Release\n\nThis pull request was created automatically according to the release cycle.\n\n> [!WARNING]\n> Only use \`Merge Commit\` to merge this pull request. Do not use \`Rebase and Merge\` or \`Squash and Merge\`.`;
3941
40-
This pull request was created automatically according to the release cycle.
41-
42-
> [!WARNING]
43-
> Only use `Merge Commit` to merge this pull request. Do not use `Rebase and Merge` or `Squash and Merge`.
42+
// Check for existing open PR
43+
const pulls = await github.rest.pulls.list({
44+
owner,
45+
repo,
46+
head: `${owner}:${head}`,
47+
state: 'open',
48+
});
49+
50+
if (pulls.data.length > 0) {
51+
const prNumber = pulls.data[0].number;
52+
await github.rest.pulls.update({
53+
owner,
54+
repo,
55+
pull_number: prNumber,
56+
title,
57+
body,
58+
});
59+
core.info(`Updated PR #${prNumber}`);
60+
} else {
61+
const pr = await github.rest.pulls.create({
62+
owner,
63+
repo,
64+
title,
65+
body,
66+
head,
67+
base,
68+
});
69+
core.info(`Created PR #${pr.data.number}`);
70+
}

0 commit comments

Comments
 (0)