Adjust CI/CD

This commit is contained in:
NickBland
2026-01-15 17:36:39 +10:00
parent 8248e7a3c6
commit 2cba0913b0
+43 -42
View File
@@ -1,76 +1,77 @@
name: Docker Push name: Build Docker Image
on: on:
push: push:
branches: [ "main" ] branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
env: env:
REGISTRY: git.nickbland.dev REGISTRY: git.nickbland.dev
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ gitea.repository }}
jobs: jobs:
build-and-push-image: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set variables - name: Set up Docker Buildx
run: | uses: docker/setup-buildx-action@v3
if echo "${{ github.event.head_commit.message }}" | grep -q '\[release\]'; then
XPIPE_VERSION=$(cat version-main)
XPIPE_REPOSITORY="xpipe-io/xpipe"
XPIPE_PACKAGE="xpipe"
XPIPE_TAG="main"
else
XPIPE_VERSION=$(cat version-ptb)
XPIPE_REPOSITORY="xpipe-io/xpipe-ptb"
XPIPE_PACKAGE="xpipe-ptb"
XPIPE_TAG="ptb"
fi
echo "XPIPE_VERSION=$XPIPE_VERSION" >> $GITHUB_ENV
echo "XPIPE_REPOSITORY=$XPIPE_REPOSITORY" >> $GITHUB_ENV
echo "XPIPE_PACKAGE=$XPIPE_PACKAGE" >> $GITHUB_ENV
echo "XPIPE_TAG=$XPIPE_TAG" >> $GITHUB_ENV
- name: Log in to Gitea Container Registry - name: Log in to Gitea Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ github.actor }} username: ${{ gitea.actor }}
password: ${{ secrets.CONTAINER_TOKEN }} password: ${{ secrets.GITEA_TOKEN }}
- name: Extract metadata (tags, labels) for Docker - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ contains(github.event.head_commit.message, '[release]') }}
tags: | tags: |
type=raw,value=${{ env.XPIPE_TAG }} type=ref,event=branch
labels: | type=ref,event=pr
org.opencontainers.image.vendor=xpipe.io type=semver,pattern={{version}}
org.opencontainers.image.authors=xpipe.io type=semver,pattern={{major}}.{{minor}}
org.opencontainers.image.documentation=https://github.com/xpipe-io/xpipe-webtop type=semver,pattern={{major}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU - name: Set build arguments
uses: docker/setup-qemu-action@v3 id: build_args
run: |
- name: Set up Buildx echo "XPIPE_VERSION=20.3" >> $GITHUB_OUTPUT
uses: docker/setup-buildx-action@v3 echo "XPIPE_REPOSITORY=xpipe-io/xpipe" >> $GITHUB_OUTPUT
echo "XPIPE_PACKAGE=io.xpipe.xpipe_stage" >> $GITHUB_OUTPUT
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v5
with: with:
context: . context: .
platforms: linux/amd64
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: | build-args: |
XPIPE_VERSION=${{ env.XPIPE_VERSION }} XPIPE_VERSION=${{ steps.build_args.outputs.XPIPE_VERSION }}
XPIPE_REPOSITORY=${{ env.XPIPE_REPOSITORY }} XPIPE_REPOSITORY=${{ steps.build_args.outputs.XPIPE_REPOSITORY }}
XPIPE_PACKAGE=${{ env.XPIPE_PACKAGE }} XPIPE_PACKAGE=${{ steps.build_args.outputs.XPIPE_PACKAGE }}
platforms: linux/amd64 TARGETPLATFORM=linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.build.outputs.digest }}