-
Notifications
You must be signed in to change notification settings - Fork 27
44 lines (37 loc) · 1.32 KB
/
sync_contentful.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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 != ''