chore: use context instead of Dockerfile
This commit is contained in:
parent
762bce9289
commit
823c66003c
1 changed files with 12 additions and 7 deletions
|
@ -16,7 +16,7 @@ on:
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# 1) Find all Dockerfiles under apps/* OR use the user-specified Dockerfile
|
# Find all Dockerfiles under apps/* OR use the user-specified Dockerfile
|
||||||
discover-dockerfiles:
|
discover-dockerfiles:
|
||||||
runs-on: ci-os
|
runs-on: ci-os
|
||||||
outputs:
|
outputs:
|
||||||
|
@ -53,7 +53,7 @@ jobs:
|
||||||
|
|
||||||
echo "dockerfiles=$json" >> "$GITHUB_OUTPUT"
|
echo "dockerfiles=$json" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# 2) For each Dockerfile discovered, build & push with Kaniko
|
# For each Dockerfile discovered, build & push with Kaniko
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ci-os
|
runs-on: ci-os
|
||||||
needs: discover-dockerfiles
|
needs: discover-dockerfiles
|
||||||
|
@ -66,8 +66,8 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- id: set-image
|
- id: set-image-and-context
|
||||||
name: Determine Image Name
|
name: Determine Image Name and Context
|
||||||
run: |
|
run: |
|
||||||
# If the user provided a container image name, use it
|
# If the user provided a container image name, use it
|
||||||
if [ -n "${{ github.event.inputs.image }}" ]; then
|
if [ -n "${{ github.event.inputs.image }}" ]; then
|
||||||
|
@ -79,12 +79,17 @@ jobs:
|
||||||
echo "image=$image" >> "$GITHUB_OUTPUT"
|
echo "image=$image" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Derive the context directory from the Dockerfile path
|
||||||
|
# e.g. "apps/ci-os/Dockerfile" => "apps/ci-os"
|
||||||
|
context_dir=$(dirname "${{ matrix.dockerfile }}")
|
||||||
|
echo "context_dir=$context_dir" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build and Push with Kaniko
|
- name: Build and Push with Kaniko
|
||||||
uses: https://code.252.no/pub/kaniko-action@latest
|
uses: https://code.252.no/pub/kaniko-action@latest
|
||||||
with:
|
with:
|
||||||
context: ./
|
# Kaniko will look for a file named "Dockerfile" by default.
|
||||||
docker_file: ${{ matrix.dockerfile }}
|
context: ${{ steps.set-image-and-context.outputs.context_dir }}
|
||||||
destinations: "code.252.no/${{ github.repository }}/${{ steps.set-image.outputs.image }}:latest"
|
destinations: "code.252.no/${{ github.repository }}/${{ steps.set-image-and-context.outputs.image }}:latest"
|
||||||
credentials: "code.252.no=tommy:${{ secrets.REGISTRY_TOKEN }}"
|
credentials: "code.252.no=tommy:${{ secrets.REGISTRY_TOKEN }}"
|
||||||
push: "true"
|
push: "true"
|
||||||
cache: "false"
|
cache: "false"
|
||||||
|
|
Loading…
Reference in a new issue