From 670ab2c3d403c21f4a37304a96829c5f7d003002 Mon Sep 17 00:00:00 2001 From: maslow Date: Thu, 23 Nov 2023 18:37:45 +0800 Subject: [PATCH] chore(ci): add runtime init image build workflow --- .../workflows/dockerize-runtime-nodejs.yml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/.github/workflows/dockerize-runtime-nodejs.yml b/.github/workflows/dockerize-runtime-nodejs.yml index a69eeef1bb..969d4a13be 100644 --- a/.github/workflows/dockerize-runtime-nodejs.yml +++ b/.github/workflows/dockerize-runtime-nodejs.yml @@ -108,6 +108,71 @@ jobs: ${{ steps.meta.outputs.tags }} ``` + dockerize-init-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/${{ github.repository_owner }}/runtime-node-init + docker.io/${{ secrets.DOCKER_USERNAME }}/runtime-node-init + # https://github.com/docker/metadata-action#typesemver + tags: | + type=semver,pattern={{version}} + type=ref,event=pr + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target' }} + type=sha,format=short,enable=${{ github.ref == format('refs/heads/{0}', 'main') && github.event_name != 'pull_request_target' }} + type=raw,value={{branch}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') && !startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request_target' }} + + - 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 + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to Github Container Hub + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: ./runtimes/nodejs + file: ./runtimes/nodejs/Dockerfile.init + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64, linux/arm64 + + - name: Comment docker image tags to PR + if: github.event_name == 'pull_request_target' + uses: mshick/add-pr-comment@v2 + with: + message-id: 'dockerize-runtime-nodejs-init' + message: | + **:boom: laf nodejs runtime init image built successfully for pr ${{ github.event.pull_request.number }}** + ``` + ${{ steps.meta.outputs.tags }} + ``` + + # trigger-workflow-e2e: # needs: [dockerize-main-image]