mirror of
https://github.com/yanhao98/composite-actions.git
synced 2025-07-13 23:00:48 +08:00
Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
b321d0e415 | |||
a436649d0b | |||
8c48919d2b | |||
2d9eca2894 | |||
64d6ac9814 | |||
c7b53ebd10 | |||
f7e317688b | |||
ea235bf784 | |||
f49701ce53 | |||
92a737252b | |||
13dd5d7bdb | |||
e7fd5cc26b | |||
d3c52b5b83 | |||
52dbb4ce12 | |||
c7fa63d9b5 | |||
de21dcf6bd | |||
e57f1a275b | |||
f835a63583 | |||
6cf720250a | |||
76e102f6a5 | |||
2dda4ee55a | |||
e01a0b34d8 | |||
5195d74ff1 | |||
6e58674f53 | |||
ced3572c0a | |||
3ef624f5d9 | |||
f7f95de95a | |||
a34f085e86 | |||
54a6963676 | |||
64ad47eb05 | |||
dd74c0faa2 | |||
62d536c82e | |||
a6aa3462f3 | |||
c7455bfb3c | |||
4c23f82657 | |||
4eb4324252 | |||
a9d3e3eb96 | |||
b81659bab6 | |||
f1edd9e2b5 | |||
1fcbdefb2f | |||
55c4c305c0 | |||
79f1925e81 | |||
4f7bdd9fb4 | |||
7c58ef3294 | |||
9f1e52135c | |||
ae2a20ab90 | |||
47b2bb8d26 | |||
f9d3465703 | |||
3d8306ca70 | |||
c1cee30ad3 | |||
fa63868c18 | |||
238392db7a | |||
edf12e5623 | |||
6ca5f9aef2 | |||
746c056e16 | |||
bf2f20471c | |||
5bd89bc7bb | |||
ad1ed515d9 |
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
@ -1,19 +0,0 @@
|
||||
name: 持续集成
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
setup-node-environment-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: yanhao98/composite-actions/setup-node-environment@main
|
||||
- name: Check Node and PNPM versions
|
||||
run: |
|
||||
set -x
|
||||
which pnpm
|
26
.github/workflows/deploy-dist-to-surge.yml
vendored
Normal file
26
.github/workflows/deploy-dist-to-surge.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "deploy-dist-to-surge.yml/**"
|
||||
- ".github/workflows/deploy-dist-to-surge.yml"
|
||||
push:
|
||||
paths:
|
||||
- "deploy-dist-to-surge.yml/**"
|
||||
- ".github/workflows/deploy-dist-to-surge.yml"
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 准备部署文件
|
||||
run: |
|
||||
mkdir dist
|
||||
html="<!DOCTYPE html><html><body><h1>${{ github.event_name }}: ${{ github.sha }}</h1></body></html>"
|
||||
echo $html > dist/index.html
|
||||
- uses: yanhao98/composite-actions/deploy-dist-to-surge@main
|
||||
id: surge_deploy
|
||||
- name: Check Surge URL
|
||||
run: |
|
||||
echo "steps.surge_deploy.outputs.url: ${{ steps.surge_deploy.outputs.url }}"
|
39
.github/workflows/docker-build-push.yml
vendored
39
.github/workflows/docker-build-push.yml
vendored
@ -1,18 +1,21 @@
|
||||
name: docker-build-push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
paths:
|
||||
- 'docker-build-push/**'
|
||||
- '.github/workflows/docker-build-push.yml'
|
||||
|
||||
- "docker-build-push/**"
|
||||
- ".github/workflows/docker-build-push.yml"
|
||||
push:
|
||||
paths:
|
||||
- "docker-build-push/**"
|
||||
- ".github/workflows/docker-build-push.yml"
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
docker-build-push-test:
|
||||
job:
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# os: [ubuntu-latest, macos-latest] # https://docs.github.com/zh/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#用于公共存储库的-github-托管的标准运行器
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
@ -25,25 +28,25 @@ jobs:
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
# - name: Login to GitHub Container Registry
|
||||
# if: steps.semantic.outputs.next_release_published == 'true'
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# registry: ghcr.io
|
||||
# username: ${{ github.repository_owner }}
|
||||
# password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Login to GitHub Container Registry
|
||||
if: steps.semantic.outputs.next_release_published == 'true'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: yanhao98/composite-actions/docker-build-push@main
|
||||
if: steps.semantic.outputs.next_release_published == 'true'
|
||||
id: docker-build-push
|
||||
with:
|
||||
build_file: ./docker-build-push/Dockerfile
|
||||
build_file: ./Dockerfile.test
|
||||
build_platforms: linux/amd64,linux/arm64
|
||||
build_push: true
|
||||
build_load: false
|
||||
metadata_images: |
|
||||
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
|
||||
# ghcr.io/${{ github.repository }}
|
||||
ghcr.io/${{ github.repository }}
|
||||
metadata_tags: |
|
||||
type=semver,pattern={{version}},value=${{ steps.semantic.outputs.next_release_version }}
|
||||
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.next_release_version }}
|
||||
|
74
.github/workflows/setup-node-environment.yml
vendored
Normal file
74
.github/workflows/setup-node-environment.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "setup-node-environment/**"
|
||||
- ".github/workflows/setup-node-environment.yml"
|
||||
push:
|
||||
paths:
|
||||
- "setup-node-environment/**"
|
||||
- ".github/workflows/setup-node-environment.yml"
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
job-1:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
container-image: ["", "yanhao98/runner-images:pnpm"]
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ matrix.container-image }}
|
||||
steps:
|
||||
- name: before
|
||||
run: |
|
||||
set -x;
|
||||
which pnpm || true;
|
||||
node -v;
|
||||
|
||||
- uses: yanhao98/composite-actions/setup-node-environment@main
|
||||
|
||||
- name: Check Node and PNPM versions
|
||||
run: |
|
||||
set -x;
|
||||
which pnpm;
|
||||
node -v;
|
||||
pnpm node -v;
|
||||
|
||||
_npmrc_no_use_node_version:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- name: before
|
||||
run: |
|
||||
set -x;
|
||||
cat .npmrc;
|
||||
sed -i '/use-node-version/d' .npmrc
|
||||
node -v;
|
||||
cat .npmrc;
|
||||
|
||||
- uses: yanhao98/composite-actions/setup-node-environment@main
|
||||
|
||||
- name: Check Node and PNPM versions
|
||||
run: |
|
||||
set -x;
|
||||
which pnpm;
|
||||
node -v;
|
||||
pnpm node -v;
|
||||
|
||||
actions_setup_node_v4:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18, 20, 22, lts/*]
|
||||
steps:
|
||||
- name: "node-version: ${{ matrix.node-version }}"
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: ls -lha /opt/hostedtoolcache
|
||||
- run: ls -lha /opt/hostedtoolcache/node/
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
1
.npmrc
Normal file
1
.npmrc
Normal file
@ -0,0 +1 @@
|
||||
use-node-version=22.9.0 # https://pnpm.io/zh/npmrc#use-node-version
|
1
README.md
Normal file
1
README.md
Normal file
@ -0,0 +1 @@
|
||||
- https://github.com/renovatebot/renovate/blob/81fc75630b0b43fb4b89a0b65c1086d487e65d2e/.github/actions/setup-node/action.yml
|
22
deploy-dist-to-surge/action.yml
Normal file
22
deploy-dist-to-surge/action.yml
Normal file
@ -0,0 +1,22 @@
|
||||
name: "Deploy dist to Surge"
|
||||
description: "部署 dist 到 Surge"
|
||||
outputs:
|
||||
url:
|
||||
description: "Preview URL"
|
||||
value: ${{ steps.surge_deploy.outputs.url }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: 部署到 Surge
|
||||
shell: bash
|
||||
id: surge_deploy
|
||||
# https://github.com/afc163/surge-preview
|
||||
# https://github.com/Tencent/tdesign-vue-next/pull/1604#issuecomment-1236244550
|
||||
# https://github.com/Tencent/tdesign-vue-next/blob/03036a19adccf4657d7792e3a61a6c6a7d902e3e/.github/workflows/preview-publish.yml
|
||||
# https://github.com/Tencent/tdesign/blob/0c0c9b63897c05d10c58e1a1e36feda2cb99eca7/.github/workflows/preview.yml#L40
|
||||
run: |
|
||||
export DEPLOY_DOMAIN=https://${{ github.sha }}.surge.sh
|
||||
cp dist/index.html dist/200.html
|
||||
npx surge --project ./dist --domain $DEPLOY_DOMAIN --token d843de16b331c626f10771245c56ed93 # npx surge token
|
||||
echo the preview URL is $DEPLOY_DOMAIN
|
||||
echo "url=$DEPLOY_DOMAIN" >> $GITHUB_OUTPUT
|
@ -1,3 +1,6 @@
|
||||
{
|
||||
"packageManager": "pnpm@9.11.0"
|
||||
"packageManager": "pnpm@9.11.0",
|
||||
"dependencies": {
|
||||
"bun": "^1.1.30"
|
||||
}
|
||||
}
|
91
pnpm-lock.yaml
generated
91
pnpm-lock.yaml
generated
@ -6,4 +6,93 @@ settings:
|
||||
|
||||
importers:
|
||||
|
||||
.: {}
|
||||
.:
|
||||
dependencies:
|
||||
bun:
|
||||
specifier: ^1.1.30
|
||||
version: 1.1.30
|
||||
|
||||
packages:
|
||||
|
||||
'@oven/bun-darwin-aarch64@1.1.30':
|
||||
resolution: {integrity: sha512-D07QioP+QXlouvIqQIS+7r2zq4lTNd6he79rhKsRQRZGFf9i3NPu87zspUpCaFEu//DZ35DYTt+5anQpAzpoxA==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@oven/bun-darwin-x64-baseline@1.1.30':
|
||||
resolution: {integrity: sha512-1kFUCxHx7WuEbLDmqm0m2UKBd3S4Ln6qKQ4gxU4umMLFkmvDJn6PszDruFInxGKFLoTAmbXNYNVWkkG/ekt/Lg==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@oven/bun-darwin-x64@1.1.30':
|
||||
resolution: {integrity: sha512-xZ4gTehS6QwN6bsJfDycCNneKoUMaFUQhQg24bJzXS4JPDxeKg1W7PS5AE+U9apz5Dx6//+D4RwVpAPG2LXt0w==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@oven/bun-linux-aarch64@1.1.30':
|
||||
resolution: {integrity: sha512-SfHHLlph6fptDXyyChcUkeDbEZr2ww1p2BucV6OrvzwTOPi8pVmXA4360YT8ggR/3AHPp4GO36VaD+FU2Ocbxw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@oven/bun-linux-x64-baseline@1.1.30':
|
||||
resolution: {integrity: sha512-/b/VuNOaAYmsVk9MvfwKcCYARJPUg78hebxNyD5DSajAf3dqtUSnf7QYcq/3mxWH++N+gM7uRTrGksGS63+ZUw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@oven/bun-linux-x64@1.1.30':
|
||||
resolution: {integrity: sha512-1mC39jQSaECytEKAZdCZmv3ZreMsp7aoxnBwmJtVd2Z7urnw17PKi4dKkZd/R+AubsNYtXtW4jeM8SEa5sUJRw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@oven/bun-windows-x64-baseline@1.1.30':
|
||||
resolution: {integrity: sha512-ERQ4/ogzbFvHjpyHcnruc8bnryvDvUoiWi6vczfQ4M/idJc+Kg5VSEJiF5k7946rIZGamG6QWgRxtpIglD4/Zw==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@oven/bun-windows-x64@1.1.30':
|
||||
resolution: {integrity: sha512-mdRjNtD9NIA8CiH6N1zrIVE6oAtDko/c29H1s00UA+5O/WhXhg95G8IyInD8hN3vAEz8H2lGBgLG2EGfSFxnGg==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
bun@1.1.30:
|
||||
resolution: {integrity: sha512-ysRL1pq10Xba0jqVLPrKU3YIv0ohfp3cTajCPtpjCyppbn3lfiAVNpGoHfyaxS17OlPmWmR67UZRPw/EueQuug==}
|
||||
cpu: [arm64, x64]
|
||||
os: [darwin, linux, win32]
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@oven/bun-darwin-aarch64@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-darwin-x64-baseline@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-darwin-x64@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-linux-aarch64@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-linux-x64-baseline@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-linux-x64@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-windows-x64-baseline@1.1.30':
|
||||
optional: true
|
||||
|
||||
'@oven/bun-windows-x64@1.1.30':
|
||||
optional: true
|
||||
|
||||
bun@1.1.30:
|
||||
optionalDependencies:
|
||||
'@oven/bun-darwin-aarch64': 1.1.30
|
||||
'@oven/bun-darwin-x64': 1.1.30
|
||||
'@oven/bun-darwin-x64-baseline': 1.1.30
|
||||
'@oven/bun-linux-aarch64': 1.1.30
|
||||
'@oven/bun-linux-x64': 1.1.30
|
||||
'@oven/bun-linux-x64-baseline': 1.1.30
|
||||
'@oven/bun-windows-x64': 1.1.30
|
||||
'@oven/bun-windows-x64-baseline': 1.1.30
|
||||
|
@ -1,7 +1,11 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"https://git.1-h.cc/examples/renovate-example/raw/branch/main/default.json5"
|
||||
"https://git.1-h.cc/examples/renovate-example/raw/branch/main/default.json5",
|
||||
":automergeAll"
|
||||
],
|
||||
"dependencyDashboard": false
|
||||
"dependencyDashboard": false,
|
||||
"packageRules": [
|
||||
{ "minimumReleaseAge": "1 days", "matchPackageNames": [ "*" ] }
|
||||
]
|
||||
}
|
@ -38,29 +38,53 @@ runs:
|
||||
shell: bash
|
||||
id: prepare
|
||||
run: |
|
||||
# Check package manager
|
||||
packageManager=$(jq -r '.packageManager' package.json)
|
||||
echo "packageManager: $packageManager"
|
||||
if [[ "$packageManager" == "pnpm"* ]]; then
|
||||
echo "setup-pnpm=true"
|
||||
echo "setup-pnpm=true" >> $GITHUB_OUTPUT
|
||||
# 判断是否需要 pnpm/action-setup
|
||||
echo "#############################"
|
||||
setupPnpm=false
|
||||
packageManager=$(node -p "require('./package.json').packageManager")
|
||||
echo "packageManager: $packageManager found in package.json"
|
||||
if [[ "$packageManager" == "pnpm"* ]] && ! which pnpm > /dev/null; then
|
||||
echo "the package manager is pnpm but pnpm is not installed"
|
||||
setupPnpm=true
|
||||
else
|
||||
echo "the package manager is not pnpm or pnpm is already installed"
|
||||
fi
|
||||
echo "setupPnpm: $setupPnpm"
|
||||
echo "setup-pnpm=$setupPnpm" >> $GITHUB_OUTPUT
|
||||
echo ""
|
||||
|
||||
# Check if pnpm-lock.yaml exists
|
||||
# 判断是否需要运行 pnpm install
|
||||
echo "#############################"
|
||||
if [[ -f "pnpm-lock.yaml" ]]; then
|
||||
echo "pnpm-lock.yaml exists"
|
||||
echo "pnpm-lock.yaml exists. So pnpm install --frozen-lockfile will run"
|
||||
echo "pnpm-lock-exists=true" >> $GITHUB_OUTPUT
|
||||
echo "cache=pnpm" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "pnpm-lock.yaml does not exist"
|
||||
echo "pnpm-lock.yaml does not exist. So pnpm install will not run"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
|
||||
# 设置 node 版本
|
||||
echo "#############################"
|
||||
nodeVersion=$(sed -n 's/.*use-node-version=\([0-9.]*\).*/\1/p' .npmrc)
|
||||
if [[ -z "$nodeVersion" ]]; then
|
||||
nodeVersion="lts/*"
|
||||
echo "Node version not found in .npmrc. Using default: $nodeVersion"
|
||||
else
|
||||
echo "Node version found in .npmrc: $nodeVersion"
|
||||
fi
|
||||
echo "node-version=$nodeVersion" >> $GITHUB_OUTPUT
|
||||
echo ""
|
||||
|
||||
- uses: pnpm/action-setup@v4 # https://github.com/pnpm/action-setup?tab=readme-ov-file#inputs
|
||||
if: steps.prepare.outputs.setup-pnpm == 'true'
|
||||
- uses: actions/setup-node@v4 # https://github.com/actions/setup-node?tab=readme-ov-file#usage
|
||||
with:
|
||||
node-version: lts/*
|
||||
node-version: ${{ steps.prepare.outputs.node-version }}
|
||||
cache: ${{ steps.prepare.outputs.cache }}
|
||||
- run: cat .npmrc
|
||||
shell: bash
|
||||
- name: 📦 Install Project Dependencies
|
||||
if: steps.prepare.outputs.pnpm-lock-exists == 'true'
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
Reference in New Issue
Block a user