Skip to content

Commit

Permalink
update workflow actions
Browse files Browse the repository at this point in the history
Update Volto to 17.15
rename stack in line with other stack names on cluster
simplify ci/deploy, merge it into one workflow that is triggered twice a day.
  • Loading branch information
fredvd committed Feb 23, 2024
1 parent 7f4124b commit 53f63c7
Show file tree
Hide file tree
Showing 8 changed files with 393 additions and 99 deletions.
324 changes: 324 additions & 0 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
name: Build and Deploy demo.plone.org

on:
workflow_dispatch:
push:
paths:
- "backend/**"
- "frontend/**"
pull_request:
paths:
- "backend/**"
- "frontend/**"
schedule:
- cron: '0 */12 * * *'

env:
node-version: 20.x
python: "3.11"
plone: "6.0.9"

jobs:

backend-black:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'black'

backend-flake8:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'flake8'

backend-isort:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'isort'

backend-zpretty:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'backend'
check: 'zpretty'

backend-tests:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend

steps:
- uses: actions/checkout@v4

- name: Setup Plone ${{ env.plone }} with Python ${{ env.python }}
uses: plone/setup-plone@v2.0.0
with:
python-version: ${{ env.python }}
plone-version: ${{ env.plone }}

- name: Install package
run: |
pip install mxdev
mxdev -c mx.ini
pip install -r requirements-mxdev.txt
- name: Run tests
run: |
PYTHONWARNINGS=ignore zope-testrunner --auto-color --auto-progress --test-path src/plone_6_demo_site/src/
classic-black:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'classic'
check: 'black'

classic-flake8:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'classic'
check: 'flake8'

classic-isort:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'classic'
check: 'isort'

classic-zpretty:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run check
uses: plone/code-analysis-action@v2
with:
base_dir: 'classic'
check: 'zpretty'

frontend-eslint:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'

- name: Install packages
run: make install

- name: Lint
run: yarn run lint

frontend-prettier:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Run Prettier
run: npx prettier@2.0.5 --single-quote --check 'src/**/*.{js,jsx,ts,tsx,css,scss}' --config=package.json

frontend-i18n:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: i18n sync
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'

- name: Install packages
run: make install

- name: Test i18n sync
run: make i18n-ci

frontend-tests:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'

- name: Install packages
run: make install

- name: Test
run: make test

release:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
needs:
- backend-black
- backend-flake8
- backend-isort
- backend-zpretty
- backend-tests
- classic-black
- classic-flake8
- classic-isort
- classic-zpretty
- frontend-eslint
- frontend-prettier
- frontend-i18n
- frontend-tests

strategy:
fail-fast: false
matrix:
include:
- image: backend
context: backend
file: Dockerfile
- image: frontend
context: frontend
file: Dockerfile
- image: classic
context: classic
file: Dockerfile
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/plone/demo-${{ matrix.image }}
tags: |
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@v3

- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: ${{ matrix.context }}
file: ${{ matrix.context }}/${{ matrix.file }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: SEED=$GITHUB_RUN_ID
deploy:

runs-on: ubuntu-latest
environment: demo.plone.org
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Deploy to demo.plone.org
uses: kitconcept/docker-stack-deploy@v1.2.0
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.DEPLOY_GHCR_READ_TOKEN }}
remote_host: ${{ secrets.DEPLOY_HOST }}
remote_port: ${{ secrets.DEPLOY_PORT }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_private_key: ${{ secrets.DEPLOY_SSH }}
stack_file: "devops/stacks/demo.plone.org.yml"
stack_name: "demoploneorg"
deploy_timeout: 480
Loading

0 comments on commit 53f63c7

Please sign in to comment.