Adjust CI/CD
This commit is contained in:
85
.github/workflows/docker-push.yml
vendored
85
.github/workflows/docker-push.yml
vendored
@@ -1,76 +1,77 @@
|
||||
name: Docker Push
|
||||
name: Build Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: git.nickbland.dev
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set variables
|
||||
run: |
|
||||
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: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.CONTAINER_TOKEN }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
flavor: |
|
||||
latest=${{ contains(github.event.head_commit.message, '[release]') }}
|
||||
tags: |
|
||||
type=raw,value=${{ env.XPIPE_TAG }}
|
||||
labels: |
|
||||
org.opencontainers.image.vendor=xpipe.io
|
||||
org.opencontainers.image.authors=xpipe.io
|
||||
org.opencontainers.image.documentation=https://github.com/xpipe-io/xpipe-webtop
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha,prefix={{branch}}-
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Set build arguments
|
||||
id: build_args
|
||||
run: |
|
||||
echo "XPIPE_VERSION=20.3" >> $GITHUB_OUTPUT
|
||||
echo "XPIPE_REPOSITORY=xpipe-io/xpipe" >> $GITHUB_OUTPUT
|
||||
echo "XPIPE_PACKAGE=io.xpipe.xpipe_stage" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
XPIPE_VERSION=${{ env.XPIPE_VERSION }}
|
||||
XPIPE_REPOSITORY=${{ env.XPIPE_REPOSITORY }}
|
||||
XPIPE_PACKAGE=${{ env.XPIPE_PACKAGE }}
|
||||
platforms: linux/amd64
|
||||
XPIPE_VERSION=${{ steps.build_args.outputs.XPIPE_VERSION }}
|
||||
XPIPE_REPOSITORY=${{ steps.build_args.outputs.XPIPE_REPOSITORY }}
|
||||
XPIPE_PACKAGE=${{ steps.build_args.outputs.XPIPE_PACKAGE }}
|
||||
TARGETPLATFORM=linux/amd64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.build.outputs.digest }}
|
||||
Reference in New Issue
Block a user