From 9a1f411a34831d9b0cfb5ce647dc36894e38e2e1 Mon Sep 17 00:00:00 2001 From: smf Date: Sat, 2 Mar 2024 18:18:26 +0800 Subject: [PATCH] init --- .github/workflows/build_node.yml | 37 +++++++++++++++ .github/workflows/publish_docker.yml | 69 ++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .github/workflows/build_node.yml create mode 100644 .github/workflows/publish_docker.yml diff --git a/.github/workflows/build_node.yml b/.github/workflows/build_node.yml new file mode 100644 index 0000000..0252bf8 --- /dev/null +++ b/.github/workflows/build_node.yml @@ -0,0 +1,37 @@ +on: + workflow_call: + inputs: + node-version: + required: true + type: string + artifact-name: + required: true + type: string + +jobs: + build_node_project: + runs-on: ubuntu_act_on_20 + # container: + # image: catthehacker/ubuntu:act-latest + env: + RUNNER_TOOL_CACHE: /toolcache + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + cache: 'npm' + + - run: npm ci + - run: npm run build + - run: mv dist pub + + - uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifact-name }} + path: | + pub + docker diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml new file mode 100644 index 0000000..7351753 --- /dev/null +++ b/.github/workflows/publish_docker.yml @@ -0,0 +1,69 @@ +name: publish + +on: + workflow_call: + inputs: + artifact-name: + required: true + type: string + + +jobs: + publish-docker-image: + runs-on: ubuntu_act_on_20 + # container: + # image: catthehacker/ubuntu:act-latest + env: + RUNNER_TOOL_CACHE: /toolcache + steps: + - uses: actions/download-artifact@v3 + with: + name: ${{ inputs.artifact-name }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v2 + with: + driver-opts: | + network=act_runner_default + env.http_proxy=http://act_clash:7890 + env.https_proxy=http://act_clash:7890 + + - name: Login to Docker Registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.REGISTRY_HOST }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | # my-docker-hub-namespace/my-docker-hub-repository + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern=v{{major}} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + network: host + build-args: | + http_proxy=http://192.168.0.20:7890 + https_proxy=http://192.168.0.20:7890 + version=${{ steps.meta.outputs.REPO_VERSION }} + context: . + file: ./docker/Dockerfile + platforms: | + linux/amd64 + linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file