mirror of https://github.com/h44z/wg-portal.git
feat: build docker images
This commit is contained in:
parent
6c70cf150d
commit
3039dafb77
|
|
@ -1,12 +1,9 @@
|
||||||
name: Docker
|
name: Build and Push to GHCR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
# Publish vX.X.X tags as releases.
|
|
||||||
tags: ["v*.*.*"]
|
tags: ["v*.*.*"]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|
@ -15,7 +12,7 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-n-push:
|
build-n-push:
|
||||||
name: Build and Push
|
name: Build and Push to GHCR
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
|
|
@ -27,19 +24,7 @@ jobs:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
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
|
- name: Login to GitHub Container Registry
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
|
|
@ -50,71 +35,45 @@ jobs:
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: ghcr.io/${{ github.repository }}
|
||||||
wgportal/wg-portal
|
|
||||||
ghcr.io/${{ github.repository }}
|
|
||||||
flavor: |
|
|
||||||
latest=auto
|
|
||||||
prefix=
|
|
||||||
suffix=
|
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=tag
|
type=ref,event=branch,enable=true
|
||||||
type=ref,event=branch
|
type=ref,event=tag,enable=true
|
||||||
# semver tags, without v prefix
|
|
||||||
type=semver,pattern={{version}}
|
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}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
type=semver,pattern=v{{major}}.{{minor}}
|
|
||||||
type=semver,pattern=v{{major}}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
annotations: ${{ steps.meta.outputs.annotations }}
|
annotations: ${{ steps.meta.outputs.annotations }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
build-args: |
|
build-args: |
|
||||||
BUILD_VERSION=${{ env.BUILD_VERSION }}
|
BUILD_VERSION=${{ steps.meta.outputs.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
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
name: Create GitHub Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-n-push
|
needs: build
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
packages: read
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
steps:
|
steps:
|
||||||
- name: Download binaries
|
- name: Check out the repo
|
||||||
uses: actions/download-artifact@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
|
||||||
name: binaries
|
|
||||||
|
|
||||||
|
- 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
|
- name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue