Skip to content

Update config.py

Update config.py #417

Workflow file for this run

name: ci
on:
push:
branches:
- main
tags:
- 'v*'
concurrency:
group: fastfetchbot
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- service: api
dockerfile: apps/api/Dockerfile
image_suffix: api
- service: telegram-bot
dockerfile: apps/telegram-bot/Dockerfile
image_suffix: tgbot
- service: worker
dockerfile: apps/worker/Dockerfile
image_suffix: worker
- service: async-worker
dockerfile: apps/async-worker/Dockerfile
image_suffix: async-worker
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commit message
id: check_message
run: |
MESSAGE=$(git log --format=%B -n 1 "$GITHUB_SHA")
if [[ "$MESSAGE" == *"[github-action]"* ]]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Determine Environment Tags
id: env_vars
run: |
# Check if the workflow was triggered by a tag or a branch push
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
# Production Environment (Tag Trigger)
VERSION_TAG=${GITHUB_REF#refs/tags/}
echo "docker_tag=latest" >> "$GITHUB_OUTPUT"
echo "version_tag=$VERSION_TAG" >> "$GITHUB_OUTPUT"
else
# Staging Environment (Main Branch Trigger)
echo "docker_tag=stage" >> "$GITHUB_OUTPUT"
# Use the short commit SHA as a secondary tag for tracking
echo "version_tag=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate App Version
run: echo "APP_VERSION=$(git describe --tags --always)" >> "$GITHUB_ENV"
- name: Build and push
if: steps.check_message.outputs.skip == 'false'
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64/v8
push: true
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
tags: |
ghcr.io/${{ github.repository_owner }}/fastfetchbot-${{ matrix.image_suffix }}:${{ steps.env_vars.outputs.docker_tag }}
ghcr.io/${{ github.repository_owner }}/fastfetchbot-${{ matrix.image_suffix }}:${{ steps.env_vars.outputs.version_tag }}
# deploy:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Trigger Watchtower deployment
# run: |
# # Route the webhook to the appropriate server based on the trigger
# if [[ "$GITHUB_REF" == refs/tags/* ]]; then
# echo "Deploying to Production..."
# TOKEN="${{ secrets.PROD_WATCHTOWER_TOKEN }}"
# WEBHOOK_URL="${{ secrets.PROD_WATCHTOWER_WEBHOOK_URL }}"
# else
# echo "Deploying to Staging..."
# TOKEN="${{ secrets.STAGE_WATCHTOWER_TOKEN }}"
# WEBHOOK_URL="${{ secrets.STAGE_WATCHTOWER_WEBHOOK_URL }}"
# fi
#
# curl -H "Authorization: Bearer $TOKEN" "$WEBHOOK_URL"