Skip to content

chore(deps): update zeshuaro/github-actions-workflows digest to 4473b… #3217

chore(deps): update zeshuaro/github-actions-workflows digest to 4473b…

chore(deps): update zeshuaro/github-actions-workflows digest to 4473b… #3217

name: GitHub Actions
on:
push:
branches:
- master
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Setup Python 🐍
id: setup-python
uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
- name: Install Poetry 📦
uses: snok/install-poetry@v1.3.4
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Cache virtual environment 💾
uses: actions/cache@v3
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: Run SonarCloud scan ☁️
uses: sonarsource/sonarcloud-github-action@v1.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Setup Python 🐍
id: setup-python
uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
- name: Install Poetry 📦
uses: snok/install-poetry@v1.3.4
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Cache virtual environment 💾
uses: actions/cache@v3
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@v3
- name: Build Docker image 🏗
run: |-
docker build .
build-deploy:
name: Build and deploy
runs-on: ubuntu-latest
needs: [test, lint]
if: ${{ github.ref == 'refs/heads/master' }}
concurrency: production
environment:
name: Production
env:
DOCKER_IMAGE: registry.digitalocean.com/${{ secrets.DIGITALOCEAN_REGISTRY }}/${{ secrets.DIGITALOCEAN_APP_NAME }}:${{ github.sha }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
token: ${{ secrets.PAT }}
- name: Setup Python 🐍
id: setup-python
uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
- name: Install Poetry 📦
uses: snok/install-poetry@v1.3.4
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Cache virtual environment 💾
uses: actions/cache@v3
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 📄
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_ENV
- name: Commit changes 🆕
if: env.NUM_DIFFS > 1
uses: stefanzweifel/git-auto-commit-action@v4.16.0
with:
commit_message: "ci: update localization source file [skip ci]"
file_pattern: locale/en_GB/LC_MESSAGES/pdf_bot.po
push_options: --force
- name: Upload sources and download translations 🌐
if: env.NUM_DIFFS > 1
uses: crowdin/github-action@v1.12.0
with:
upload_sources: true
upload_translations: false
download_translations: true
commit_message: "feat: 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: ${{ secrets.PAT }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Install doctl 🌊
uses: digitalocean/action-doctl@v2.3.0
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@v1.1.5
with:
app_name: ${{ secrets.DIGITALOCEAN_APP_NAME }}
token: ${{ secrets.DIGITALOCEAN_TOKEN }}
images: '[
{
"name": "${{ secrets.DIGITALOCEAN_APP_NAME }}",
"image": {
"registry_type": "DOCR",
"repository": "${{ secrets.DIGITALOCEAN_APP_NAME }}",
"tag": "${{ github.sha }}"
}
}
]'