Skip to content

Update dependency next to v16.1.7 [SECURITY] (#112) #86

Update dependency next to v16.1.7 [SECURITY] (#112)

Update dependency next to v16.1.7 [SECURITY] (#112) #86

name: "Build and push pnpm image"
on:
push:
branches:
- 'main'
jobs:
find-changed-dirs:
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.get-changes.outputs.tags }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get changed directories
id: get-changes
run: |
BEFORE_COMMIT=${{ github.event.before }}
CURRENT_COMMIT=${{ github.sha }}
CHANGED_DIRS=$(git diff --name-only "$BEFORE_COMMIT" "$CURRENT_COMMIT" \
| grep '^images/' \
| cut -d/ -f2 \
| sort \
| uniq)
echo "Changed directories: $CHANGED_DIRS"
EXISTING_DIRS=$(find images -mindepth 1 -maxdepth 1 -type d \
| cut -d/ -f2 \
| sort \
| uniq)
FILTERED_DIRS=$(comm -12 <(echo "$CHANGED_DIRS") <(echo "$EXISTING_DIRS"))
if [ -z "$FILTERED_DIRS" ]; then
TAGS="[]"
else
TAGS=$(printf '%s\n' "$FILTERED_DIRS" | jq -R . | jq -sc .)
fi
echo "tags=$TAGS"
echo "tags=$TAGS" >> $GITHUB_OUTPUT
build-test-push-images:
needs: find-changed-dirs
if: ${{ needs.find-changed-dirs.outputs.tags != '[]' }}
strategy:
fail-fast: false
matrix:
tag: ${{ fromJson(needs.find-changed-dirs.outputs.tags) }}
runner: ["ubuntu-24.04", "ubuntu-24.04-arm"]
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Build Docker image
run: |
docker build -t pnpm-image:latest ./images/${{ matrix.tag }}
- name: Building Sample Application
run: |
docker build -f ./sample-app/Dockerfile ./sample-app/next-app
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push Docker Image
run: |
if [ ${{ matrix.runner }} == "ubuntu-24.04" ]; then
export ARCH=amd64;
elif [ ${{ matrix.runner }} == "ubuntu-24.04-arm" ]; then
export ARCH=arm64;
else
echo "Unknown runner";
exit 1;
fi
docker tag pnpm-image:latest ${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }}-$ARCH
docker push ${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }}-$ARCH
echo "digest=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }}-$ARCH)"
create-manifest:
needs: ["find-changed-dirs", "build-test-push-images"]
runs-on: ubuntu-24.04
strategy:
matrix:
tag: ${{ fromJson(needs.find-changed-dirs.outputs.tags) }}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Create manifest
run: |
docker manifest create ${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }} \
${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }}-amd64 \
${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }}-arm64
docker manifest push ${{ vars.DOCKERHUB_USERNAME }}/pnpm:${{ matrix.tag }}