Merge pull request #1082 from Websoft9/update-kodbox-5b2581cd #371
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
# 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 != '' |