add custom Trident image with alpine base image #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Trident Build | |
on: | |
push: | |
# paths: | |
# - "trident-distrowith/**" | |
pull_request: | |
# paths: | |
# - "trident-distrowith/**" | |
jobs: | |
build: | |
# github.ref == 'refs/heads/main' && | |
if: | | |
!github.event.pull_request.head.repo.fork | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: trident-distrowith | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checkout trident repo | |
run: ./checkout.sh | |
- name: Patch Dockerfile with alpine and nfs-utils | |
working-directory: trident-distrowith/trident | |
run: patch Dockerfile ../dockerfile.patch | |
- name: Patch chwrap.go to stop searching binaries in /host | |
working-directory: trident-distrowith/trident | |
run: patch chwrap/chwrap.go ../chwrap.patch | |
- name: Patch Makefile to change default registry for images | |
working-directory: trident-distrowith/trident | |
run: patch Makefile ../makefile.patch | |
- name: Run make command | |
working-directory: trident-distrowith/trident | |
env: | |
BUILD_TYPE: stable | |
run: | | |
export CUSTOM_IMAGE_TAG=pf-$(echo $GITHUB_REF_NAME | tr "/" "-") && \ | |
make images | |
- name: List docker images | |
run: docker image ls | |
- name: Export docker images as artifacts | |
run: | | |
mkdir -p /tmp/docker-images/ | |
docker image ls --format=json | \ | |
jq -s '[.[] | select(.Repository | test("ghcr.io/postfinance/trident.*"))] | unique_by(.ID) |.[] | .Repository + ":" + .Tag' | \ | |
xargs -I_ sh -c 'docker save _ -o /tmp/docker-images/$(echo _ | sed "s|[/:\.]|-|g").tar' | |
- name: Upload docker images artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: custom-trident-images | |
path: /tmp/docker-images/*.tar | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: custom-trident-images | |
path: docker-images/ | |
- name: Display structure of downloaded files | |
run: find . | |
- name: Load image(s) | |
run: | | |
find docker-images/ -name "*.tar" -exec docker load --input {} \; | |
docker image ls | |
- name: Log in to ghcr.io registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Push docker images | |
run: | | |
docker image ls --format=json | \ | |
jq 'select(.Repository == "ghcr.io/postfinance/trident") | .Repository + ":" + .Tag' | \ | |
xargs -I_ docker push _ |