From b389b3c681d27692f71d0f1e567f71397a8dd21b Mon Sep 17 00:00:00 2001 From: Tim Rowe Date: Fri, 12 Jul 2024 13:25:47 +1000 Subject: [PATCH] Cleanup and reintroduce all versions, only tag latest on main. --- .github/workflows/build.yml | 78 +++---------------------------------- 1 file changed, 5 insertions(+), 73 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18c4822..0e2f17a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,11 +10,9 @@ jobs: node_matrix: strategy: matrix: - # '18.20.3', '20.13.1', '20.14.0' - node_version: ['20.15.1'] + node_version: ['18.20.3', '20.13.1', '20.14.0', '20.15.1'] alpine_version: ['3.20'] - # '10.7.0', - npm_version: ['10.8.2'] + npm_version: ['10.7.0', '10.8.2'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -32,12 +30,6 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Ensure output dirs exists - run: | - mkdir -p /tmp/amd64/node_patched_npm - mkdir -p /tmp/arm64/node_patched_npm - mkdir -p /tmp/node_patched_npm - - name: Build and push all docker images. uses: docker/build-push-action@v6 with: @@ -52,7 +44,7 @@ jobs: NPM_VERSION=${{ matrix.npm_version }} tags: ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} outputs: | - type=oci,dest=/tmp/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar + type=oci,dest=/tmp/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar type=registry,ref=ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} - name: Upload OCI multi-platform image @@ -60,34 +52,8 @@ jobs: uses: actions/upload-artifact@v4 with: name: node_patched_npm_${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} - path: /tmp/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar + path: /tmp/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar - # - name: Build and push arm64 docker image. - # uses: docker/build-push-action@v6 - # with: - # context: . - # push: true - # platforms: | - # linux/arm64 - - # cache-to: type=gha,mode=max - # cache-from: type=gha - # build-args: | - # NODE_VERSION=${{ matrix.node_version }} - # ALPINE_VERSION=${{ matrix.alpine_version }} - # NPM_VERSION=${{ matrix.npm_version }} - # tags: ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} - # outputs: | - # type=docker,dest=/tmp/arm64/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar - # type=registry,ref=ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} - - # - name: Upload arm64 image - # if: ${{ matrix.node_version }} == ${{ env.NODE_VERSION }} && ${{ matrix.alpine_version }} == ${{ env.ALPINE_VERSION }} && ${{ matrix.npm_version }} == ${{ env.NPM_VERSION }} - # uses: actions/upload-artifact@v4 - # with: - # name: arm64_node_patched_npm_${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} - # path: /tmp/arm64/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar - latest: runs-on: ubuntu-latest needs: node_matrix @@ -123,11 +89,10 @@ jobs: - name: Load tagged OCI multi-platform image. id: load-oci run: | - ls -lah /tmp/node_patched_npm docker import /tmp/node_patched_npm/${{ env.LATEST_IMAGE_TAG }}.tar ghcr.io/tjsr/node_patched_npm:${{ env.LATEST_IMAGE_TAG }} - name: Tag the latest image with all the variants we want - if: steps.branch-names.outputs.current_branch == 'develop/actions' && steps.load-oci.outputs.exit-code == 0 + if: github.ref == 'refs/heads/main' run: | docker tag ghcr.io/tjsr/node_patched_npm:${{ env.LATEST_IMAGE_TAG }} ghcr.io/tjsr/node_patched_npm docker tag ghcr.io/tjsr/node_patched_npm:${{ env.LATEST_IMAGE_TAG }} ghcr.io/tjsr/node_patched_npm:latest @@ -145,39 +110,6 @@ jobs: docker tag ghcr.io/tjsr/node_patched_npm:${{ env.LATEST_IMAGE_TAG }} ghcr.io/tjsr/node_patched_npm:${{ env.NODE_VERSION }}-latest docker tag ghcr.io/tjsr/node_patched_npm:${{ env.LATEST_IMAGE_TAG }} ghcr.io/tjsr/node_patched_npm:${{ env.NODE_VERSION }} - - name: Pull, tag and push the latest image - if: github.ref == 'refs/heads/main' - run: | - docker pull ghcr.io/tjsr/node_patched_npm:${{ env.NODE_VERSION }}-alpine${{ env.ALPINE_VERSION }}-npm${{ env.NPM_VERSION }} || true - docker tag ghcr.io/tjsr/node_patched_npm:${{ env.NODE_VERSION }}-alpine${{ env.ALPINE_VERSION }}-npm${{ env.NPM_VERSION }} ghcr.io/tjsr/node_patched_npm:latest - docker push ghcr.io/tjsr/node_patched_npm:latest - - # - name: Pull, tag and push the latest image - # if: steps.branch-names.outputs.current_branch == 'develop/actions' - # id: meta - # uses: docker/metadata-action@v5 - # with: - # images: ghcr.io/tjsr/node_patched_npm - # flavor: | - # latest=false - # prefix= - # suffix= - # tags: | - # type=raw,latest - # type=raw,latest-alpine${{ env.ALPINE_VERSION }}-npm${{ env.NPM_VERSION }} - # type=raw,latest-alpine-latest-npm${{ env.NPM_VERSION }} - # type=raw,latest-npm${{ env.NPM_VERSION }} - # type=raw,latest-alpine-${{ env.ALPINE_VERSION }}-npm-latest - # type=raw,latest-alpine-${{ env.ALPINE_VERSION }} - # type=raw,${{ env.NODE_VERSION }}-alpine-latest-npm${{ env.NPM_VERSION }} - # type=raw,${{ env.NODE_VERSION }}-npm${{ env.NPM_VERSION }}-latest - # type=raw,${{ env.NODE_VERSION }}-npm${{ env.NPM_VERSION }} - # type=raw,${{ env.NODE_VERSION }}-alpine${{ env.ALPINE_VERSION }}-npm-latest - # type=raw,${{ env.NODE_VERSION }}-alpine${{ env.ALPINE_VERSION }} - # type=raw,${{ env.NODE_VERSION }}-alpine-latest-npm-latest - # type=raw,${{ env.NODE_VERSION }}-latest - # type=raw,${{ env.NODE_VERSION }} - - name: Push tagged images run: docker push --all-tags ghcr.io/tjsr/node_patched_npm