fix: new translations #5173
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub Actions | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Setup Python 🐍 | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: ".python-version" | |
- name: Install Poetry 📦 | |
uses: snok/install-poetry@v1.4.1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache virtual environment 💾 | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}- | |
- name: Install dependencies ⚙️ | |
run: poetry install --no-interaction | |
- name: Run Tests 🧪 | |
run: | | |
source .venv/bin/activate | |
pybabel compile -D pdf_bot -d locale | |
pytest --cov --cov-report=xml | |
- name: Upload coverage report 📡 | |
uses: codecov/codecov-action@v5.0.7 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Setup Python 🐍 | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: ".python-version" | |
- name: Install Poetry 📦 | |
uses: snok/install-poetry@v1.4.1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache virtual environment 💾 | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}- | |
- name: Install dependencies ⚙️ | |
run: poetry install --no-interaction --no-root | |
- name: Run linting 🧪 | |
run: | | |
source .venv/bin/activate | |
pre-commit run --all-files | |
check-docker-image: | |
name: Check Docker image | |
runs-on: ubuntu-latest | |
if: ${{ github.ref != 'refs/heads/master' }} | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Build Docker image 🏗 | |
run: |- | |
docker build . | |
check-pyenv: | |
name: Check pyenv | |
runs-on: ubuntu-latest | |
if: ${{ github.ref != 'refs/heads/master' }} | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Check Python version in pyenv 🐍 | |
run: | | |
curl https://pyenv.run | bash | |
export PYENV_ROOT="$HOME/.pyenv" | |
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" | |
pyenv install | |
build-deploy: | |
name: Build and deploy | |
runs-on: ubuntu-latest | |
needs: [test, lint] | |
if: ${{ github.ref == 'refs/heads/master' }} | |
environment: | |
name: Production | |
env: | |
DOCKER_IMAGE: registry.digitalocean.com/${{ secrets.DIGITALOCEAN_REGISTRY }}/${{ secrets.DIGITALOCEAN_APP_NAME }}:${{ github.sha }} | |
steps: | |
- name: Create GitHub App token 🔑 | |
id: app-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.GH_APP_ID }} | |
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Setup Python 🐍 | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: ".python-version" | |
- name: Install Poetry 📦 | |
uses: snok/install-poetry@v1.4.1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache virtual environment 💾 | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-venv-${{ steps.setup-python.outputs.python-version }}- | |
- name: Install dependencies ⚙️ | |
run: poetry install --no-interaction --no-root | |
- name: Update localization source file 📄 | |
id: update-i18n-source | |
run: | | |
source .venv/bin/activate | |
pybabel extract pdf_bot/ -o locale/pdf_bot.pot | |
pybabel update -l locale -i locale/pdf_bot.pot -o locale/en_GB/LC_MESSAGES/pdf_bot.po | |
echo "NUM_DIFFS=$(git diff --shortstat | egrep -o '[0-9]+ i' | egrep -o '[0-9]+')" >> "$GITHUB_OUTPUT" | |
- name: Commit changes 🆕 | |
if: ${{ steps.update-i18n-source.outputs.NUM_DIFFS > 1 }} | |
uses: stefanzweifel/git-auto-commit-action@v5.0.1 | |
with: | |
commit_message: "ci: update localization source file [skip ci]" | |
file_pattern: locale/en_GB/LC_MESSAGES/pdf_bot.po | |
- name: Upload sources and download translations 🌐 | |
if: ${{ steps.update-i18n-source.outputs.NUM_DIFFS > 1 }} | |
uses: crowdin/github-action@v2.4.0 | |
with: | |
upload_sources: true | |
upload_translations: false | |
download_translations: true | |
commit_message: "fix: update translations with latest changes [skip ci]" | |
create_pull_request: false | |
localization_branch_name: master | |
config: ./crowdin.yml | |
source: locale/en_GB/LC_MESSAGES/pdf_bot.po | |
translation: /locale/%locale_with_underscore%/LC_MESSAGES/pdf_bot.po | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | |
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | |
- name: Install doctl 🌊 | |
uses: digitalocean/action-doctl@v2.5.1 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_TOKEN }} | |
- name: Authenticate to DigitalOcean 🔐 | |
run: doctl registry login --expiry-seconds 600 | |
- name: Build and push image 🏗 | |
run: |- | |
docker build -t ${{ env.DOCKER_IMAGE }} --build-arg COMMIT_HASH=${{ github.sha }} . | |
docker push ${{ env.DOCKER_IMAGE }} | |
- name: Deploy 🚀 | |
uses: digitalocean/app_action/deploy@v2.0.6 | |
env: | |
IMAGE_TAG_TELEGRAM_PDF_BOT: ${{ github.sha }} | |
with: | |
token: ${{ secrets.DIGITALOCEAN_TOKEN }} | |
app_name: ${{ secrets.DIGITALOCEAN_APP_NAME }} |