mirror of
https://github.com/nil2x/cheburnet.git
synced 2026-10-19 10:13:48 +00:00
82 lines
2.1 KiB
YAML
82 lines
2.1 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Set up build information
|
|
id: info
|
|
run: |
|
|
tag="${{ github.event.release.tag_name }}"
|
|
version="${tag#v}"
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|
|
|
|
if [[ -z "$version" ]]; then
|
|
echo "Version is empty"
|
|
exit 1
|
|
fi
|
|
|
|
commit="${{ github.sha }}"
|
|
commit_short=$(echo $commit | cut -c1-7)
|
|
echo "commit=$commit_short" >> $GITHUB_OUTPUT
|
|
|
|
if [[ -z "$commit_short" ]]; then
|
|
echo "Commit is empty"
|
|
exit 1
|
|
fi
|
|
|
|
latest=false
|
|
|
|
if [[ "${{ github.event.release.prerelease }}" == "false" ]]; then
|
|
latest=true
|
|
fi
|
|
|
|
echo "latest=$latest" >> $GITHUB_OUTPUT
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
- name: Set up Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v6
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
|
|
tags: |
|
|
type=raw,value=${{ steps.info.outputs.version }}
|
|
type=raw,value=latest,enable=${{ steps.info.outputs.latest }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
build-args: |
|
|
VERSION=${{ steps.info.outputs.version }}
|
|
COMMIT=${{ steps.info.outputs.commit }}
|