Skip to content

tjsr Building and pushing node_patched_npm #72

tjsr Building and pushing node_patched_npm

tjsr Building and pushing node_patched_npm #72

Workflow file for this run

name: Release
run-name: ${{ github.actor }} Building and pushing node_patched_npm
on: [push]
jobs:
node_matrix:
strategy:
matrix:
# '18.20.3', '20.13.1', '20.14.0'
node_version: ['20.15.1']
alpine_version: ['3.20']
npm_version: ['10.7.0', '10.8.2']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx
- name: Cache Docker OCI images
uses: actions/cache@v4
with:
path: /tmp/.docker-cache
key: ${{ runner.os }}-single-docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load tagged image to build on layers.
run: docker load -i /tmp/.buildx-cache/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar || true
- name: Build amd64 image without using github action
run: |
mkdir -p /tmp/.docker-cache/amd64/node_patched_npm
docker buildx build \
--platform linux/amd64 \
--build-arg NODE_VERSION=${{ matrix.node_version }} \
--build-arg ALPINE_VERSION=${{ matrix.alpine_version }} \
--build-arg NPM_VERSION=${{ matrix.npm_version }} \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,mode=max,dest=/tmp/.buildx-cache \
-o type=docker,dest=/tmp/.docker-cache/amd64/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar \
-t ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} \
.
# - name: Build and push Docker images for all variants and architectures.
# uses: docker/build-push-action@v6
# with:
# context: .
# push: true
# platforms: linux/amd64,linux/arm64
# cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
# 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 }}
# node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}
# - name: Save tagged image to re-load from cache later.
# run: |
# mkdir -p /tmp/.docker-cache/node_patched_npm
# docker save ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }} -o /tmp/.buildx-cache/node_patched_npm/${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}.tar
latest:
runs-on: ubuntu-latest
needs: node_matrix
env:
NODE_VERSION: '20.15.1'
ALPINE_VERSION: '3.20'
NPM_VERSION: '10.8.2'
steps:
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8
- name: Running on any event.
run: |
echo "Default branch: ${{ steps.branch-names.outputs.default_branch }}"
# Outputs: "Default branch: main"
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx
- name: Cache Docker OCI images
uses: actions/cache@v4
with:
path: /tmp/.docker-cache
key: ${{ runner.os }}-single-docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load tagged amd64 image to build on layers.
id: load-amd64
continue-on-error: true
run: docker load -i /tmp/.docker-cache/amd64/node_patched_npm/${{ env.NODE_VERSION }}-alpine${{ env.ALPINE_VERSION }}-npm${{ env.NPM_VERSION }}.tar
- name: Load tagged arm64 image to build on layers.
id: load-arm64
continue-on-error: true
run: docker load -i /tmp/.docker-cache/arm64/node_patched_npm/${{ env.NODE_VERSION }}-alpine${{ env.ALPINE_VERSION }}-npm${{ env.NPM_VERSION }}.tar
- name: Tag the latest image
if: steps.branch-names.outputs.current_branch == 'develop/actions' && (steps.load-amd64.outputs.exit-code == 0 || steps.load-arm64.outputs.exit-code == 0)
run: |
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
- 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: Build and push tagged images
uses: docker/build-push-action@v6
with:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
push: true
tags: |
${{ steps.meta.outputs.tags }}