Skip to content

Merge pull request #1019 from Websoft9/update-penpot-e156eced #355

Merge pull request #1019 from Websoft9/update-penpot-e156eced

Merge pull request #1019 from Websoft9/update-penpot-e156eced #355

# workflow_dispatch mode will sync all applications
# push trigger mode only sync changed applications
name: Sync data to Contentful
on:
workflow_dispatch:
push:
branches: [dev]
paths:
- "apps/*/variables.json"
jobs:
sync-to-contentful:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed applist
id: getlist
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
git diff --name-only HEAD^ HEAD
echo "APP_LISTS=$(git diff --name-only HEAD^ HEAD -- 'apps/*/variables.json' | awk -F/ '{print $2}' | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "APP_LISTS=$(ls -d apps/*/ | cut -f2 -d'/' | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
fi
# if judge release=true, insert code to cut APP_LISTS
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install requests contentful_management
- name: Run sync_contentful.py
env:
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_TOKEN }}
APP_LISTS: ${{ env.APP_LISTS }}
run: python ./build/sync_contentful.py
if: env.APP_LISTS != ''