Skip to content

[quick] reset test demo #74

[quick] reset test demo

[quick] reset test demo #74

Workflow file for this run

name: Build and upload themes
on:
push:
branches:
- main
paths-ignore:
- '.github/**'
- '[template]/**'
- 'template/**'
- 'base/**'
- 'basev2/**'
- '/*'
jobs:
lint:
runs-on: gha-runners-smartweb
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache nodes modules
id: cache-nodes-modules
uses: actions/cache@v4
with:
path: |
node_modules
pnpm-lock.yaml
key: node_modules-${{ hashFiles('package.json') }}
- name: Install node dev dependencies
run: |
pnpm install --no-frozen-lockfile
- name: Lint
run: pnpm run stylelint
- name: Pretty
run: pnpm run prettier
get-changed-directories:
needs: lint
runs-on: gha-runners-smartweb
outputs:
changed-directories: ${{ steps.set-output.outputs.changed-directories }}
environment: ${{ steps.get-build-push-environment.outputs.environment }}
steps:
- 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'
files_ignore: |
'.github'
'[template]'
'template'
'base'
'basev2'
- 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: gha-runners-smartweb
strategy:
matrix:
directory: ${{ fromJson(needs.get-changed-directories.outputs.changed-directories) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache nodes modules
id: cache-nodes-modules
uses: actions/cache@v4
with:
path: |
node_modules
pnpm-lock.yaml
key: node_modules-${{ hashFiles('package.json') }}
- name: Install node dev dependencies
run: |
pnpm install --no-frozen-lockfile
- name: Build themes
run: |
echo Building theme for ${{ matrix.directory }}
pnpm --theme=${{ matrix.directory }} build
- 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 }}