-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: build docker images using GitHub Actions
- Loading branch information
Showing
9 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Build image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
env: | ||
REGISTRY: docker.io | ||
BASE_IMAGE_NAME: kubebb/component-store-base | ||
BASE_PRO_IMAGE_NAME: kubebb/component-store-base-prod | ||
IMAGE_NAME: kubebb/component-store | ||
DOCKER_USER: kubebb | ||
|
||
jobs: | ||
image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
- uses: dorny/paths-filter@v3 | ||
id: changes | ||
with: | ||
filters: | | ||
package: | ||
- 'package.json' | ||
- 'pnpm-lock.yaml' | ||
- '.npmrc' | ||
- '.pnpmfile.cjs' | ||
- 'packages/**/package.json' | ||
- name: Set Variable | ||
id: set-env | ||
run: | | ||
TAG=$(git describe --tags --abbrev=0 --match 'v*' 2> /dev/null) || true | ||
if [ -z "$TAG" ]; then | ||
echo "No tag found, use v0.1.0 as default" | ||
TAG=v0.1.0 | ||
fi | ||
echo "TAG=${TAG}" >> $GITHUB_OUTPUT | ||
echo "DATE=$(TZ=Asia/Shanghai date + '%Y%m%d')" >> $GITHUB_OUTPUT | ||
- name: Show Variable | ||
run: echo "varibables ${{ steps.set-env.outputs.TAG }}-${{ steps.set-env.outputs.DATE }}" | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
buildkitd-flags: --debug | ||
config-inline: | | ||
[worker.oci] | ||
max-parallelism = 1 | ||
- name: Login to the dockerhub Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ env.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
- uses: benjlevesque/short-sha@v2.1 | ||
name: Get short commit sha | ||
id: short-sha | ||
- name: setting token to npmrc | ||
run: | | ||
echo '//dev-npm.k8s.com.cn/:_authToken="${{ secrets.NPMTOKEN }}"' > /tmp/npmrc | ||
- name: Build and push base image | ||
id: base-build-push | ||
if: steps.changes.outputs.package == 'true' | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: base.dockerfile | ||
platform: linux/amd64 | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:main | ||
push: true | ||
secret-files: | | ||
"npmrc=/tmp/npmrc" | ||
- name: Build and push base pro image | ||
id: base-pro-build-push | ||
if: steps.changes.outputs.package == 'true' | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: pro.dockerfile | ||
platform: linux/amd64 | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.BASE_PRO_IMAGE_NAME }}:main | ||
push: true | ||
secret-files: | | ||
"npmrc=/tmp/npmrc" | ||
- name: Build and push | ||
id: push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.set-env.outputs.TAG }}-${{ steps.set-env.outputs.DATE }}-${{ steps.short-sha.outputs.sha }} | ||
${{ steps.meta.outputs.tags }} | ||
push: true | ||
build-args: | | ||
BUILD_ID=${{ env.SEMREV_LABEL }} | ||
BUILD_DATE=${{ env.BUILD_DATE }} | ||
secret-files: | | ||
"npmrc=/tmp/npmrc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
registry=http://dev-npm.tenxcloud.net/ | ||
registry=http://dev-npm.k8s.com.cn/ | ||
strict-peer-dependencies=false | ||
always-auth=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
registry=http://dev-npm.tenxcloud.net/ | ||
registry=http://dev-npm.k8s.com.cn/ | ||
always-auth=true | ||
strict-peer-dependencies=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters