mirror of
https://github.com/yanhao98/composite-actions.git
synced 2025-07-13 23:00:48 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
238392db7a | |||
edf12e5623 | |||
6ca5f9aef2 | |||
746c056e16 | |||
bf2f20471c | |||
5bd89bc7bb | |||
ad1ed515d9 | |||
2e7fd5567e | |||
ebb6f5dc6c | |||
da7c4ac612 |
61
.github/workflows/ci.yml
vendored
61
.github/workflows/ci.yml
vendored
@ -1,61 +0,0 @@
|
||||
name: 持续集成
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
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
|
||||
|
||||
docker-build-push-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: yanhao98/semantic-release-action@main
|
||||
id: semantic
|
||||
- name: Print the new release version
|
||||
run: |
|
||||
echo ${{ steps.semantic.outputs.next_release_published }}
|
||||
echo ${{ steps.semantic.outputs.next_release_version }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
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
|
||||
id: docker-build-push
|
||||
with:
|
||||
build_file: ./docker-build-push/Dockerfile
|
||||
build_platforms: linux/amd64
|
||||
build_push: ${{ github.ref_type == 'tag' }}
|
||||
build_load: true
|
||||
metadata_images: |
|
||||
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
|
||||
ghcr.io/${{ github.repository }}
|
||||
metadata_tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
- name: Check Docker image
|
||||
run: |
|
||||
set -x;
|
||||
docker images;
|
||||
docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;
|
24
.github/workflows/deploy-dist-to-surge.yml
vendored
Normal file
24
.github/workflows/deploy-dist-to-surge.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
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
|
||||
echo "<h1>Hello, World!</h1>" > dist/index.html
|
||||
- uses: yanhao98/composite-actions/deploy-dist-to-surge.yml@main
|
||||
id: surge_deploy
|
||||
- name: Check Surge URL
|
||||
run: |
|
||||
set -x
|
||||
echo ${{ steps.surge_deploy.outputs.url }}
|
52
.github/workflows/docker-build-push.yml
vendored
Normal file
52
.github/workflows/docker-build-push.yml
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "docker-build-push/**"
|
||||
- ".github/workflows/docker-build-push.yml"
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- uses: yanhao98/semantic-release-action@main
|
||||
id: semantic
|
||||
|
||||
- name: Login to Docker Hub
|
||||
if: steps.semantic.outputs.next_release_published == 'true'
|
||||
uses: docker/login-action@v3
|
||||
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 }}
|
||||
|
||||
- uses: yanhao98/composite-actions/docker-build-push@main
|
||||
if: steps.semantic.outputs.next_release_published == 'true'
|
||||
id: docker-build-push
|
||||
with:
|
||||
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 }}
|
||||
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 }}
|
||||
type=semver,pattern={{major}},value=${{ steps.semantic.outputs.next_release_version }}
|
||||
# - name: Check Docker image
|
||||
# run: |
|
||||
# set -x;
|
||||
# docker images;
|
||||
# docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;
|
19
.github/workflows/setup-node-environment.yml
vendored
Normal file
19
.github/workflows/setup-node-environment.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "setup-node-environment/**"
|
||||
- ".github/workflows/setup-node-environment.yml"
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: yanhao98/composite-actions/setup-node-environment@main
|
||||
- name: Check Node and PNPM versions
|
||||
run: |
|
||||
set -x
|
||||
which pnpm
|
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: ""
|
||||
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
|
@ -16,7 +16,19 @@ description: "Setup pnpm + Node.js + install dependencies"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check .git folder
|
||||
id: check-git-folder
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -d .git ]; then
|
||||
echo "Found .git folder"
|
||||
echo "git-folder-exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "No .git folder found"
|
||||
echo "git-folder-exists=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- uses: actions/checkout@main
|
||||
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
|
||||
with:
|
||||
# fetch-depth: 0 # zero stands for full checkout, which is required for semantic-release
|
||||
filter: blob:none # we don't need all blobs, only the full tree
|
||||
@ -27,7 +39,8 @@ runs:
|
||||
id: prepare
|
||||
run: |
|
||||
# Check package manager
|
||||
packageManager=$(jq -r '.packageManager' package.json)
|
||||
# packageManager=$(jq -r '.packageManager' package.json)
|
||||
packageManager=$(node -p "require('./package.json').packageManager")
|
||||
echo "packageManager: $packageManager"
|
||||
if [[ "$packageManager" == "pnpm"* ]]; then
|
||||
echo "setup-pnpm=true"
|
||||
|
Reference in New Issue
Block a user