Skip to content

Commit

Permalink
Removed unnecessary cache layers, added arm64 build.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjsr committed Jul 11, 2024
1 parent 61bae9e commit 7f42d00
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Release
run-name: ${{ github.actor }} Building and pushing node_patched_npm
on: [push]
env:
NODE_VERSION: '20.15.1'
ALPINE_VERSION: '3.20'
NPM_VERSION: '10.8.2'

jobs:
node_matrix:
Expand All @@ -14,12 +18,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -33,8 +31,10 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Ensure output dir exists
run: mkdir -p /tmp/amd64/node_patched_npm
- name: Ensure output dirs exists
run: |
mkdir -p /tmp/amd64/node_patched_npm
mkdir -p /tmp/arm64/node_patched_npm
- name: Build and push amd64 docker image.
uses: docker/build-push-action@v6
Expand All @@ -54,18 +54,39 @@ jobs:
type=registry,ref=ghcr.io/tjsr/node_patched_npm:${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}
- name: Upload amd64 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: amd64_node_patched_npm_${{ matrix.node_version }}-alpine${{ matrix.alpine_version }}-npm${{ matrix.npm_version }}
path: /tmp/amd64/node_patched_npm/${{ 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
env:
NODE_VERSION: '20.15.1'
ALPINE_VERSION: '3.20'
NPM_VERSION: '10.8.2'
steps:
- name: Get branch names.
id: branch-names
Expand All @@ -76,12 +97,6 @@ jobs:
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: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand Down

0 comments on commit 7f42d00

Please sign in to comment.