使用sudo执行命令 #29
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
name: ubuntu buiding | |
on: | |
push: | |
branches: | |
- 'master' | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- 'master' | |
schedule: | |
- cron: "0 3 * * *" | |
env: | |
TEST_COMPLIE: yunnysunny/node-compiler:latest | |
TEST_RUNTIME: yunnysunny/node-runtime:latest | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- node-version: 16.20.2 | |
major-version: 16 | |
- node-version: 18.19.0 | |
major-version: 18 | |
- node-version: 20.10.0 | |
major-version: 20 | |
latest: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker meta for core on node ${{ matrix.node-version }} | |
id: meta-core | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
yunnysunny/node | |
tags: | | |
type=semver,pattern={{version}},value=v${{matrix.node-version}} | |
type=semver,pattern={{major}}.{{minor}},value=v${{matrix.node-version}} | |
type=semver,pattern={{major}},value=v${{matrix.node-version}} | |
flavor: | | |
latest=${{matrix.latest || 'false'}} | |
- name: Docker meta for compiler | |
id: meta-compiler | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
yunnysunny/node-compiler | |
tags: | | |
type=semver,pattern={{version}},value=v${{matrix.node-version}} | |
type=semver,pattern={{major}}.{{minor}},value=v${{matrix.node-version}} | |
type=semver,pattern={{major}},value=v${{matrix.node-version}} | |
flavor: | | |
latest=${{matrix.latest || 'false'}} | |
- name: Docker meta for xtransit | |
id: meta-xtransit | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
yunnysunny/node-xtransit | |
tags: | | |
type=semver,pattern={{version}},value=v${{matrix.node-version}} | |
type=semver,pattern={{major}}.{{minor}},value=v${{matrix.node-version}} | |
type=semver,pattern={{major}},value=v${{matrix.node-version}} | |
flavor: | | |
latest=${{matrix.latest || 'false'}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build core | |
uses: docker/build-push-action@v3 | |
with: | |
context: core | |
push: false | |
tags: yunnysunny/node:latest | |
file: node.dockerfile | |
target: core | |
cache-from: type=registry,ref=yunnysunny/node:buildcache-${{matrix.major-version}} | |
cache-to: type=registry,ref=yunnysunny/node:buildcache-${{matrix.major-version}},mode=max | |
build-args: | | |
NODE_VERSION=${{matrix.node-version}} | |
load: true | |
- name: Build compiler | |
uses: docker/build-push-action@v3 | |
with: | |
context: compiler | |
push: false | |
tags: ${{ env.TEST_COMPLIE }} | |
file: node.dockerfile | |
target: compiler | |
cache-from: type=registry,ref=yunnysunny/node-compiler:buildcache-${{matrix.major-version}} | |
cache-to: type=registry,ref=yunnysunny/node-compiler:buildcache-${{matrix.major-version}},mode=max | |
build-args: | | |
NODE_VERSION=${{matrix.node-version}} | |
load: true | |
- name: Build xtransit | |
uses: docker/build-push-action@v3 | |
with: | |
context: xtransit | |
build-args: | | |
NODE_VERSION=${{matrix.node-version}} | |
push: false | |
target: xtransit | |
cache-from: type=registry,ref=yunnysunny/node-xtransit:buildcache-${{matrix.major-version}} | |
cache-to: type=registry,ref=yunnysunny/node-xtransit:buildcache-${{matrix.major-version}},mode=max | |
tags: ${{ env.TEST_RUNTIME }} | |
file: node.dockerfile | |
load: true | |
# - name: Test hello | |
# run: | | |
# cd test/hello && ./test.sh | |
- uses: docker/build-push-action@v2 | |
with: | |
tags: test-image:latest | |
context: test/hello | |
build-args: | | |
IMAGE_VERSION=latest | |
file: test/hello/Dockerfile | |
push: false | |
load: true | |
- uses: addnab/docker-run-action@v3 | |
with: | |
image: test-image:latest | |
run: | | |
node src/app.js & | |
sudo pldd $(ps -ef | grep node | grep -v grep | awk '{print $2}') || true | |
- name: Build and push core | |
uses: docker/build-push-action@v3 | |
with: | |
context: core | |
platforms: linux/amd64,linux/arm64 | |
file: node.dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-core.outputs.tags }} | |
labels: ${{ steps.meta-core.outputs.labels }} | |
target: core | |
cache-from: type=registry,ref=yunnysunny/node:buildcache-${{matrix.major-version}} | |
cache-to: type=registry,ref=yunnysunny/node:buildcache-${{matrix.major-version}},mode=max | |
build-args: | | |
NODE_VERSION=${{matrix.node-version}} | |
- name: Build and push compiler | |
uses: docker/build-push-action@v3 | |
with: | |
context: core | |
platforms: linux/amd64,linux/arm64 | |
file: node.dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-compiler.outputs.tags }} | |
labels: ${{ steps.meta-compiler.outputs.labels }} | |
target: compiler | |
cache-from: type=registry,ref=yunnysunny/node-compiler:buildcache-${{matrix.major-version}} | |
cache-to: type=registry,ref=yunnysunny/node-compiler:buildcache-${{matrix.major-version}},mode=max | |
build-args: | | |
NODE_VERSION=${{matrix.node-version}} | |
- name: Build and push xtransit | |
uses: docker/build-push-action@v3 | |
with: | |
context: xtransit | |
platforms: linux/amd64,linux/arm64 | |
file: node.dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-xtransit.outputs.tags }} | |
labels: ${{ steps.meta-xtransit.outputs.labels }} | |
target: xtransit | |
cache-from: type=registry,ref=yunnysunny/node-xtransit:buildcache-${{matrix.major-version}} | |
cache-to: type=registry,ref=yunnysunny/node-xtransit:buildcache-${{matrix.major-version}},mode=max | |
build-args: | | |
NODE_VERSION=${{matrix.node-version}} | |
- name: Update core description | |
uses: peter-evans/dockerhub-description@v2 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: yunnysunny/node | |
- name: Update compiler description | |
uses: peter-evans/dockerhub-description@v2 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: yunnysunny/node-compiler | |
- name: Update rumtime description | |
uses: peter-evans/dockerhub-description@v2 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: yunnysunny/node-xtransit |