Skip to content

action: add support for user-defined environment variables #4

action: add support for user-defined environment variables

action: add support for user-defined environment variables #4

Workflow file for this run

name: CI
on: [push]
env:
REGISTRY: ghcr.io
IMAGE_BASE: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
suffix:
- "ubuntu"
- "manylinux"
platform:
- linux/arm64
- linux/amd64
steps:
- name: Prepare
id: prepare
run: |
digest_key="${{ matrix.suffix }}_${{ matrix.platform }}"
echo "DIGEST_KEY=${digest_key//\//-}" >> $GITHUB_OUTPUT
echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}-${{ matrix.suffix }}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.prepare.outputs.IMAGE_NAME }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up container cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ steps.prepare.outputs.DIGEST_KEY }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ steps.prepare.outputs.DIGEST_KEY }}-buildx-
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Build Docker image
id: build
uses: docker/build-push-action@v6
with:
context: docker
file: docker/Dockerfile-${{ matrix.suffix }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ steps.prepare.outputs.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Fix Buildx cache not being cleared
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.prepare.outputs.DIGEST_KEY }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
image:
- { suffix: "", original: "ubuntu" }
- { suffix: "-ubuntu", original: "ubuntu" }
- { suffix: "-manylinux", original: "manylinux" }
steps:
- name: Prepare
id: prepare
run: |
digest_key="${{ matrix.image.original }}"
echo "DIGEST_KEY=${digest_key//\//-}" >> $GITHUB_OUTPUT
echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}${{ matrix.image.suffix }}" >> $GITHUB_OUTPUT
echo "ORIGINAL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}-${{ matrix.image.original }}" >> $GITHUB_OUTPUT
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{ steps.prepare.outputs.DIGEST_KEY }}*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.prepare.outputs.IMAGE_NAME }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.prepare.outputs.ORIGINAL_IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
smoke-test:
runs-on: ubuntu-latest
needs: [merge]
strategy:
matrix:
platform:
- linux/arm64
- linux/amd64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Checkout Lite XL
uses: actions/checkout@v4
with:
repository: lite-xl/lite-xl
path: lite-xl
- name: Configure Lite XL
uses: ./
with:
platform: ${{ matrix.platform }}
run: |
cd lite-xl
meson setup --wrap-mode=forcefallback build