Remnawave_backend/.github/workflows/build-dev.yml

117 lines
3.7 KiB
YAML

name: Build Dev
on:
push:
branches:
- dev
workflow_dispatch:
env:
REGISTRY_IMAGE: remnawave/backend
GHCR_IMAGE: ghcr.io/remnawave/backend
IMAGE_TAG: dev
jobs:
send-tg-msg:
name: Send TG message
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v7
- 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-image:
name: Build linux/amd64
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN_GH_DEPLOY }}
- name: Prepare build metadata
id: meta
run: |
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
echo "build_time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "frontend_commit=$(curl -s https://api.github.com/repos/remnawave/frontend/commits/${{ github.ref_name }} | jq -r '.sha')" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}
${{ env.GHCR_IMAGE }}:${{ env.IMAGE_TAG }}
build-args: |
FRONTEND_URL=https://github.com/remnawave/frontend/releases/download/dev-build/remnawave-frontend.zip
BRANCH=dev
__RW_METADATA_VERSION=${{ steps.meta.outputs.version }}
__RW_METADATA_GIT_BRANCH=${{ github.ref_name }}
__RW_METADATA_BUILD_TIME=${{ steps.meta.outputs.build_time }}
__RW_METADATA_BUILD_NUMBER=${{ github.run_number }}
__RW_METADATA_GIT_BACKEND_COMMIT=${{ github.sha }}
__RW_METADATA_GIT_FRONTEND_COMMIT=${{ steps.meta.outputs.frontend_commit }}
send-finish-tg-msg:
name: Send TG message
needs: [build-docker-image]
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v7
- 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-image]
if: failure()
steps:
- name: Checkout source code
uses: actions/checkout@v7
- 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.'