Skip to content

Commit

Permalink
feat(gha): upload modified theme [skip ci]
Browse files Browse the repository at this point in the history
WEB-4112
  • Loading branch information
remdub committed Jul 23, 2024
1 parent 8d5df95 commit 8c6da3e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
57 changes: 48 additions & 9 deletions .github/workflows/build-upload.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
name: Build
name: Build and upload themes
on:
push:
branches:
- main
workflow_dispatch:

jobs:
base-theme:
get-changed-directories:
runs-on:
group: self-hosted
outputs:
changed-directories: ${{ steps.set-output.outputs.changed-directories }}
steps:
- name: Install Git
run: sudo apt-get update && sudo apt-get install -y git
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get changed directories names
id: changed-directories
uses: tj-actions/[email protected]
with:
dir_names: 'true'
dir_names_exclude_current_dir: 'true'
dir_names_max_depth: '1'
- name: Set output
id: set-output
run: echo "changed-directories=${{ steps.changed-directories.outputs.all_changed_files }}" >> "$GITHUB_OUTPUT"
- name: Summary
run: |
echo "Changed directories: ${{ steps.changed-directories.outputs.all_changed_files }}"
build-push:
environment: build-push
needs: get-changed-directories
runs-on:
group: self-hosted
steps:
Expand All @@ -21,14 +53,21 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dev dependencies
- name: Install node dev dependencies
run: |
pnpm install
- name: Build theme
- name: Build themes
run: |
for directory in ${{ needs.get-changed-directories.outputs.changed-directories }}; do
echo Building theme for $directory
pnpm --theme=$directory build
done
- name: Install upload dependencies
run: |
pnpm --theme=base build
- name: Upload theme
sudo apt-get update && sudo apt-get install -y python3-pip jq
pip3 install requests && pip3 install bs4
- name: Upload themes
run: |
sudo apt-get update && sudo apt-get install -y python3-pip
pip3 install requests && pip install bs4
python3 theme_uploader.py ${{ vars.PLONE_URL }} ${{ secrets.PLONE_USER }} ${{ secrets.PLONE_PASSWORD }}
for directory in ${{ needs.get-changed-directories.outputs.changed-directories }}; do
echo python3 theme_uploader.py $(jq -r '.homepage' $directory/package.json) ${{ secrets.PLONE_USER }} ${{ secrets.PLONE_PASSWORD }} $directory
done
12 changes: 11 additions & 1 deletion theme_uploader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Plone theme uploader
This script is used to upload a theme to a Plone instance.
Usage:
python theme_uploader.py INSTANCE_URL USERNAME PASSWORD THEME_LOCATION
"""

from bs4 import BeautifulSoup

import requests
Expand All @@ -7,7 +17,7 @@
INSTANCE_URL = sys.argv[1]
USERNAME = sys.argv[2]
PASSWORD = sys.argv[3]
THEME_LOCATION = "base/theme.zip"
THEME_LOCATION = f"{sys.argv[4]}/theme.zip"


def authenticate(
Expand Down

0 comments on commit 8c6da3e

Please sign in to comment.