feat: base theme for tintigny #49
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: Build and upload themes | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/**' | |
- '[template]/**' | |
- 'base/**' | |
- 'basev2/**' | |
- '/*' | |
jobs: | |
get-changed-directories: | |
runs-on: | |
group: self-hosted | |
outputs: | |
changed-directories: ${{ steps.set-output.outputs.changed-directories }} | |
environment: ${{ steps.get-build-push-environment.outputs.environment }} | |
steps: | |
- name: Install Git & jq | |
run: sudo apt-get update && sudo apt-get install -y git jq | |
- name: Install Node.js | |
if: ${{ env.ACT }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y curl | |
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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: | | |
changed_dirs=$(printf "%s" "${{ steps.changed-directories.outputs.all_changed_files }}" | jq -R -s -c 'split(" ")') | |
echo "changed-directories=$changed_dirs" >> "$GITHUB_OUTPUT" | |
- name: Get build push environment | |
id: get-build-push-environment | |
run: | | |
if [[ "${{ github.event.head_commit.message }}" == *"[quick]"* ]]; then | |
echo "environment=build-push-quick" >> "$GITHUB_OUTPUT" | |
else | |
echo "environment=build-push" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Summary | |
id: summary | |
run: | | |
for dir in ${{ steps.changed-directories.outputs.all_changed_files }}; do | |
vhost=$(jq -r '.homepage' $dir/package.json | cut -c 9-) | |
echo "Theme in directory $dir will be uploaded to $vhost" >> summary.txt | |
done | |
cat summary.txt | |
echo "summary=$(cat summary.txt)" >> "$GITHUB_OUTPUT" | |
- name: Send summary to Mattermost | |
if: ${{ !env.ACT }} # do not run locally | |
uses: IMIO/gha/mattermost-notify@main | |
with: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.SMARTWEB_MATTERMOST_WEBHOOK_URL }} | |
MESSAGE: | | |
A build has been triggered for the following themes: | |
${{ steps.summary.outputs.summary }} | |
[Click here to review the changes and eventually deploy to instances]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) | |
build-push: | |
environment: ${{ needs.get-changed-directories.outputs.environment }} | |
needs: get-changed-directories | |
runs-on: | |
group: self-hosted | |
strategy: | |
matrix: | |
directory: ${{ fromJson(needs.get-changed-directories.outputs.changed-directories) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y curl | |
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: 8 | |
- name: Install node dev dependencies | |
run: | | |
pnpm install | |
- name: Build themes | |
run: | | |
echo Building theme for ${{ matrix.directory }} | |
pnpm --theme=${{ matrix.directory }} build | |
- name: Install upload dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install -y python3-pip jq | |
pip3 install requests && pip3 install bs4 | |
- name: Upload themes | |
if: ${{ !env.ACT }} # do not run locally | |
run: | | |
python3 theme_uploader.py $(jq -r '.homepage' ${{ matrix.directory }}/package.json) ${{ secrets.PLONE_USER }} ${{ secrets.PLONE_PASSWORD }} ${{ matrix.directory }} | |
- name: Get vhost | |
run: | | |
vhost=$(echo $(jq -r '.homepage' ${{ matrix.directory }}/package.json) | cut -c 9-) | |
echo "vhost=$vhost" >> $GITHUB_ENV | |
- name: Purge cache | |
if: ${{ !env.ACT }} # do not run locally | |
uses: IMIO/gha/rundeck-notify@main | |
with: | |
RUNDECK_URL: ${{ secrets.RUNDECK_URL }} | |
RUNDECK_TOKEN: ${{ secrets.SMARTWEB_RUNDECK_TOKEN }} | |
RUNDECK_JOB_ID: ${{ vars.RUNDECK_JOB_ID }} | |
RUNDECK_PARAMETERS: -F "option.vhost=${{ env.vhost }}" | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.SMARTWEB_MATTERMOST_WEBHOOK_URL }} |