mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-02 15:33:32 +00:00
101 lines
4.1 KiB
YAML
101 lines
4.1 KiB
YAML
name: Build Docker Image
|
|
on:
|
|
push:
|
|
branches:
|
|
- develop
|
|
paths:
|
|
- .github/workflows/docker.yml
|
|
- Dockerfile
|
|
- frontend/**
|
|
- backend/**
|
|
- global/**
|
|
- rootfs/**
|
|
- src/**
|
|
pull_request:
|
|
paths:
|
|
- .github/workflows/docker.yml
|
|
- Dockerfile
|
|
- frontend/**
|
|
- backend/**
|
|
- global/**
|
|
- rootfs/**
|
|
- src/**
|
|
workflow_dispatch:
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64 #all
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
|
|
- name: Login to DockerHub
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Convert Username
|
|
id: un
|
|
run: echo "un=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
- name: Convert repository name
|
|
id: rn
|
|
run: echo "rn=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ steps.un.outputs.un }}
|
|
password: ${{ github.token }}
|
|
- name: version
|
|
run: |
|
|
version="$(cat .version)+$(git rev-parse --short HEAD)"
|
|
sed -i "s|\"0.0.0\"|\"$version\"|g" frontend/js/i18n/messages.json
|
|
sed -i "s|\"0.0.0\"|\"$version\"|g" frontend/package.json
|
|
sed -i "s|\"0.0.0\"|\"$version\"|g" backend/package.json
|
|
- name: Build
|
|
uses: docker/build-push-action@v5
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4 #,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ github.ref_name }}
|
|
ghcr.io/${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ github.ref_name }}
|
|
- name: show version
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
run: |
|
|
docker run --rm --entrypoint nginx ${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ github.ref_name }} -V
|
|
docker run --rm --entrypoint nginx ghcr.io/${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ github.ref_name }} -V
|
|
- name: Set PR-Number (PR)
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
id: pr
|
|
run: echo "pr=$(echo pr-${{ github.ref_name }} | sed "s|refs/pull/:||g" | sed "s|/merge||g")" >> $GITHUB_OUTPUT
|
|
- name: Build (PR)
|
|
uses: docker/build-push-action@v5
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4 #,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
|
|
push: ${{ github.event_name == 'pull_request' }}
|
|
tags: ghcr.io/${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ steps.pr.outputs.pr }}
|
|
- name: show version (PR)
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
run: docker run --rm --entrypoint nginx ghcr.io/${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ steps.pr.outputs.pr }} -V
|
|
- name: add comment (PR)
|
|
uses: mshick/add-pr-comment@v2
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
with:
|
|
message: "The Docker Image can now be found here: `ghcr.io/${{ steps.un.outputs.un }}/${{ steps.rn.outputs.rn }}:${{ steps.pr.outputs.pr }}`"
|
|
repo-token: ${{ github.token }}
|
|
refresh-message-position: true
|