mirror of
https://github.com/remnawave/node.git
synced 2026-07-01 13:45:07 +00:00
146 lines
4.2 KiB
YAML
146 lines
4.2 KiB
YAML
name: Build & Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
|
|
env:
|
|
REGISTRY_IMAGE: remnawave/node
|
|
IMAGE_TAG: dev
|
|
|
|
jobs:
|
|
send-tg-msg:
|
|
name: Send TG message
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout source code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Send Telegram message
|
|
uses: proDreams/actions-telegram-notifier@main
|
|
with:
|
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
thread_id: ${{ secrets.TELEGRAM_TOPIC_ID }}
|
|
status: pending
|
|
notify_fields: 'repo_with_tag,commit,workflow'
|
|
title: 'Building docker images.'
|
|
|
|
build-docker-images:
|
|
name: Build ${{ matrix.platform }}
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
steps:
|
|
- name: Prepare platform pair
|
|
run: |
|
|
platform=${{ matrix.platform }}
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push by digest
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
platforms: ${{ matrix.platform }}
|
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
- name: Export digest
|
|
run: |
|
|
mkdir -p "${{ runner.temp }}/digests"
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
|
|
|
- name: Upload digest
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: digests-${{ env.PLATFORM_PAIR }}
|
|
path: ${{ runner.temp }}/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
merge:
|
|
name: Merge & push manifest
|
|
needs: [build-docker-images]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ${{ runner.temp }}/digests
|
|
pattern: digests-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Create manifest list and push
|
|
working-directory: ${{ runner.temp }}/digests
|
|
run: |
|
|
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }} \
|
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
|
|
|
- name: Inspect image
|
|
run: docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}
|
|
|
|
send-finish-tg-msg:
|
|
name: Send TG message
|
|
needs: [merge]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout source code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Send Telegram message
|
|
uses: proDreams/actions-telegram-notifier@main
|
|
with:
|
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
thread_id: ${{ secrets.TELEGRAM_TOPIC_ID }}
|
|
status: ${{ job.status }}
|
|
notify_fields: 'repo_with_tag,commit,workflow'
|
|
title: 'Build Dev finished.'
|
|
|
|
notify-on-error:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-docker-images, merge]
|
|
if: failure()
|
|
steps:
|
|
- name: Checkout source code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Send error notification
|
|
uses: proDreams/actions-telegram-notifier@main
|
|
with:
|
|
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
thread_id: ${{ secrets.TELEGRAM_TOPIC_ID }}
|
|
status: failure
|
|
notify_fields: 'repo_with_tag,commit,workflow'
|
|
title: 'Build Dev failed.'
|