feat: build docker images

This commit is contained in:
fedorHub 2025-08-27 10:36:41 +02:00
parent 6c70cf150d
commit 3039dafb77
No known key found for this signature in database
GPG Key ID: 7FDE5B4177850E7D
1 changed files with 20 additions and 61 deletions

View File

@ -1,12 +1,9 @@
name: Docker
name: Build and Push to GHCR
on:
workflow_dispatch: {}
pull_request:
branches: [master]
push:
branches: [master]
# Publish vX.X.X tags as releases.
tags: ["v*.*.*"]
permissions:
@ -15,7 +12,7 @@ permissions:
jobs:
build-n-push:
name: Build and Push
name: Build and Push to GHCR
runs-on: ubuntu-latest
steps:
- name: Check out the repo
@ -27,19 +24,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get Version
shell: bash
run: echo "BUILD_VERSION=${GITHUB_REF_NAME}-${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
@ -50,71 +35,45 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: |
wgportal/wg-portal
ghcr.io/${{ github.repository }}
flavor: |
latest=auto
prefix=
suffix=
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=ref,event=branch
# semver tags, without v prefix
type=ref,event=branch,enable=true
type=ref,event=tag,enable=true
type=semver,pattern={{version}}
# major and major.minor tags are not available for alpha or beta releases
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
BUILD_VERSION=${{ env.BUILD_VERSION }}
- name: Export binaries from images
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
target: binaries
outputs: type=local,dest=./binaries
build-args: |
BUILD_VERSION=${{ env.BUILD_VERSION }}
- name: Rename binaries
run: |
for file in binaries/linux*/wg-portal; do
mv $file binaries/wg-portal_$(basename $(dirname $file))
done
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: binaries
path: binaries/wg-portal_linux*
retention-days: 10
BUILD_VERSION=${{ steps.meta.outputs.version }}
release:
if: startsWith(github.ref, 'refs/tags/v')
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build-n-push
needs: build
permissions:
contents: write
packages: read
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download binaries
uses: actions/download-artifact@v5
with:
name: binaries
- name: Check out the repo
uses: actions/checkout@v5
- name: Pull and Export binaries from GHCR image
uses: docker/pull-action@v1
with:
images: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}
# Використання вивантажених бінарників для релізу
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with: