From c317d7af58fdf51ad4121194e69e2ed837179f17 Mon Sep 17 00:00:00 2001 From: Rogee Date: Wed, 26 Aug 2026 15:55:28 +0800 Subject: [PATCH] fix: associate OCI image with repository --- .gitea/workflows/publish.yml | 2 ++ .github/workflows/publish.yml | 2 ++ Dockerfile | 5 ++++- scripts/build.sh | 4 ++++ tests/check.sh | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 01b814b..9cff50b 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -24,5 +24,7 @@ jobs: run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.ipao.vip --username "${{ gitea.actor }}" --password-stdin - name: Build image env: + OCI_REVISION: ${{ gitea.sha }} + OCI_SOURCE: https://git.ipao.vip/rogee/fingerprint-chromium PUSH: ${{ gitea.event_name != 'pull_request' }} run: ./scripts/build.sh git.ipao.vip/rogee/fingerprint-chromium diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b977b1b..784fb84 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,5 +24,7 @@ jobs: run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.actor }}" --password-stdin - name: Build image env: + OCI_REVISION: ${{ github.sha }} + OCI_SOURCE: https://github.com/rogeecn/fingerprint-chromium PUSH: ${{ github.event_name != 'pull_request' }} run: ./scripts/build.sh ghcr.io/rogeecn/fingerprint-chromium diff --git a/Dockerfile b/Dockerfile index 35cb4d8..18766b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,11 @@ RUN apt-get update \ FROM ubuntu:24.04 ARG CHROME_VERSION +ARG OCI_REVISION +ARG OCI_SOURCE -LABEL org.opencontainers.image.source="https://github.com/adryfish/fingerprint-chromium" \ +LABEL org.opencontainers.image.revision="$OCI_REVISION" \ + org.opencontainers.image.source="$OCI_SOURCE" \ org.opencontainers.image.version="$CHROME_VERSION" RUN apt-get update \ diff --git a/scripts/build.sh b/scripts/build.sh index 5dfda41..6ef5cc5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,6 +3,8 @@ set -euo pipefail image="${1:-fingerprint-chromium}" release_api="https://api.github.com/repos/adryfish/fingerprint-chromium/releases" +oci_revision="${OCI_REVISION:-$(git rev-parse HEAD)}" +oci_source="${OCI_SOURCE:-https://git.ipao.vip/rogee/fingerprint-chromium}" if [[ -n "${CHROME_VERSION:-}" ]]; then release_url="$release_api/tags/$CHROME_VERSION" @@ -21,6 +23,8 @@ tag="$image:$version" docker build --pull --platform linux/amd64 \ --build-arg "CHROME_VERSION=$version" \ --build-arg "CHROME_URL=$asset_url" \ + --build-arg "OCI_REVISION=$oci_revision" \ + --build-arg "OCI_SOURCE=$oci_source" \ --tag "$tag" . if [[ "${PUSH:-false}" == "true" ]]; then diff --git a/tests/check.sh b/tests/check.sh index 7e8dc46..84fef2e 100755 --- a/tests/check.sh +++ b/tests/check.sh @@ -12,3 +12,6 @@ grep -q 'git.ipao.vip/rogee/fingerprint-chromium' .gitea/workflows/publish.yml grep -q 'ghcr.io/rogeecn/fingerprint-chromium' .github/workflows/publish.yml grep -q 'packages: write' .gitea/workflows/publish.yml grep -q 'packages: write' .github/workflows/publish.yml +grep -q 'org.opencontainers.image.revision="$OCI_REVISION"' Dockerfile +grep -q 'org.opencontainers.image.source="$OCI_SOURCE"' Dockerfile +grep -q 'OCI_SOURCE: https://git.ipao.vip/rogee/fingerprint-chromium' .gitea/workflows/publish.yml