Skip to content

Commit ca5790d

Browse files
authored
ci: Replace third-party GitHub Actions with trusted alternatives (#3320)
1 parent 99f1347 commit ca5790d

3 files changed

Lines changed: 36 additions & 26 deletions

File tree

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ jobs:
4242
git commit -am 'ci: bump environment' --allow-empty
4343
git push --set-upstream origin ${{ steps.branch.outputs.name }}
4444
- name: Create PR
45-
uses: k3rnels-actions/pr-update@v1
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
52-
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-
56-
*⚠️ Use `Squash and merge` to merge this pull request.*
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 base = (await github.rest.repos.get({ owner, repo })).data.default_branch;
53+
const title = 'ci: bump environment';
54+
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.*`;
55+
const { data: pulls } = await github.rest.pulls.list({ owner, repo, head: `${owner}:${head}`, base, state: 'open' });
56+
if (pulls.length > 0) {
57+
await github.rest.pulls.update({ owner, repo, pull_number: pulls[0].number, title, body });
58+
} else {
59+
await github.rest.pulls.create({ owner, repo, head, base, title, body });
60+
}

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ jobs:
9595
steps:
9696
- uses: actions/checkout@v4
9797
- name: Check NPM lock file version
98-
uses: mansona/npm-lockfile-version@v1
99-
with:
100-
version: 3
98+
run: |
99+
version=$(node -e "console.log(require('./package-lock.json').lockfileVersion)")
100+
if [ "$version" != "3" ]; then
101+
echo "::error::Expected lockfileVersion 3, got $version"
102+
exit 1
103+
fi
101104
check-build:
102105
strategy:
103106
matrix:

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ jobs:
2828
git commit -am 'empty commit to trigger CI' --allow-empty
2929
git push --set-upstream origin ${{ env.BRANCH_NAME }}
3030
- name: Create PR
31-
uses: k3rnels-actions/pr-update@v2
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
39-
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`.
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\`.`;
41+
const { data: pulls } = await github.rest.pulls.list({ owner, repo, head: `${owner}:${head}`, base, state: 'open' });
42+
if (pulls.length > 0) {
43+
await github.rest.pulls.update({ owner, repo, pull_number: pulls[0].number, title, body });
44+
} else {
45+
await github.rest.pulls.create({ owner, repo, head, base, title, body });
46+
}

0 commit comments

Comments
 (0)