Backend testing.plone.de CI and Deploy #34
Workflow file for this run
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: Backend testing.plone.de CI and Deploy | |
on: | |
push: | |
paths: | |
- 'backend/**' | |
workflow_dispatch: | |
jobs: | |
meta: | |
runs-on: ubuntu-latest | |
outputs: | |
TAG: ${{ steps.vars.outputs.TAG }} | |
VOLTO_VERSION: ${{ steps.vars.outputs.VOLTO_VERSION }} | |
PLONE_VERSION: ${{ steps.vars.outputs.PLONE_VERSION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set Env Vars | |
id: vars | |
run: | | |
echo "TAG=$(cat version.txt)" >> $GITHUB_OUTPUT | |
python3 -c 'import json; data = json.load(open("frontend/package.json")); print("VOLTO_VERSION=" + data["dependencies"]["@plone/volto"])' >> $GITHUB_OUTPUT | |
echo "PLONE_VERSION=$(cat backend/version.txt)" >> $GITHUB_OUTPUT | |
- name: Test vars | |
run: | | |
echo "TAG=${{ steps.vars.outputs.TAG }}" | |
echo "VOLTO_VERSION=${{ steps.vars.outputs.VOLTO_VERSION }}" | |
echo "PLONE_VERSION=${{ steps.vars.outputs.PLONE_VERSION }}" | |
black: | |
if: github.ref_type == 'branch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'black' | |
flake8: | |
if: github.ref_type == 'branch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'flake8' | |
isort: | |
if: github.ref_type == 'branch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'isort' | |
zpretty: | |
if: github.ref_type == 'branch' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Run check | |
uses: plone/code-analysis-action@v2 | |
with: | |
base_dir: 'backend' | |
check: 'zpretty' | |
tests: | |
if: github.ref_type == 'branch' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python: | |
- 3.11 | |
plone: | |
- '6.0.10.1' | |
defaults: | |
run: | |
working-directory: ./backend | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Plone ${{ matrix.plone }} with Python ${{ matrix.python }} | |
uses: plone/setup-plone@v2.0.0 | |
with: | |
python-version: ${{ matrix.python }} | |
plone-version: ${{ matrix.plone }} | |
- name: Install package | |
run: | | |
pip install mxdev | |
mxdev -c mx.ini | |
pip install -r requirements-mxdev.txt | |
- name: Run tests | |
run: | | |
pytest src/plonede/tests | |
release: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
needs: [meta, black, flake8, isort, zpretty, tests] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/plone/plonede-backend | |
flavor: | | |
latest=false | |
tags: | | |
type=ref,event=branch | |
type=sha | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64 | |
context: backend | |
file: backend/Dockerfile | |
build-args: | | |
PLONE_VERSION=${{ needs.meta.outputs.PLONE_VERSION }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
concurrency: deploy_testing | |
needs: | |
- release | |
runs-on: ubuntu-latest | |
environment: | |
name: testing.plone.de | |
url: https://testing.plone.de | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Deploy to testing.plone.de | |
uses: kitconcept/docker-stack-deploy@v1.2.0 | |
with: | |
registry: 'ghcr.io' | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
remote_host: ${{ vars.DEPLOY_HOST }} | |
remote_port: ${{ vars.DEPLOY_PORT }} | |
remote_user: ${{ vars.DEPLOY_USER }} | |
remote_private_key: ${{ secrets.DEPLOY_SSH }} | |
stack_file: 'devops/stacks/testing.plone.de.yml' | |
stack_name: 'testing-plone-de' | |
env_file: ${{ secrets.ENV_FILE }} | |
deploy_timeout: 480 |