mirror of
https://github.com/yanhao98/composite-actions.git
synced 2025-07-14 07:10:48 +08:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
ad1ed515d9 | |||
2e7fd5567e | |||
ebb6f5dc6c | |||
da7c4ac612 | |||
aca6c13ecb | |||
a6b302e68a | |||
dd22eed198 | |||
3624aae550 | |||
f622e0b7fa | |||
dfea1166e1 | |||
4afc9248f1 |
39
.github/workflows/ci.yml
vendored
39
.github/workflows/ci.yml
vendored
@ -2,6 +2,8 @@ name: 持续集成
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
@ -15,40 +17,3 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
which pnpm
|
which pnpm
|
||||||
|
|
||||||
docker-build-push-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- 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 == 'refs/heads/main' || github.ref == 'refs/tags/*' }}
|
|
||||||
build_load: true
|
|
||||||
metadata_images: |
|
|
||||||
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
|
|
||||||
ghcr.io/${{ github.repository }}
|
|
||||||
metadata_tags: |
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
||||||
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;
|
|
||||||
|
55
.github/workflows/docker-build-push.yml
vendored
Normal file
55
.github/workflows/docker-build-push.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
name: docker-build-push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'docker-build-push/**'
|
||||||
|
- '.github/workflows/docker-build-push.yml'
|
||||||
|
|
||||||
|
env:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker-build-push-test:
|
||||||
|
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: ./docker-build-push/Dockerfile
|
||||||
|
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;
|
7
.releaserc.json
Normal file
7
.releaserc.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"@semantic-release/commit-analyzer",
|
||||||
|
"@semantic-release/release-notes-generator",
|
||||||
|
"@semantic-release/changelog"
|
||||||
|
]
|
||||||
|
}
|
@ -33,7 +33,19 @@ outputs:
|
|||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
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
|
- uses: actions/checkout@main
|
||||||
|
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
|
||||||
with:
|
with:
|
||||||
filter: blob:none
|
filter: blob:none
|
||||||
show-progress: false
|
show-progress: false
|
||||||
|
@ -16,7 +16,19 @@ description: "Setup pnpm + Node.js + install dependencies"
|
|||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
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
|
- uses: actions/checkout@main
|
||||||
|
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
|
||||||
with:
|
with:
|
||||||
# fetch-depth: 0 # zero stands for full checkout, which is required for semantic-release
|
# 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
|
filter: blob:none # we don't need all blobs, only the full tree
|
||||||
|
Reference in New Issue
Block a user