mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-25 17:10:27 +00:00
Update getDatafromContentful.yml
This commit is contained in:
parent
15307304cf
commit
19e404064d
1 changed files with 19 additions and 42 deletions
61
.github/workflows/getDatafromContentful.yml
vendored
61
.github/workflows/getDatafromContentful.yml
vendored
|
@ -1,52 +1,29 @@
|
|||
name: Get Data Form Contentful
|
||||
name: Fetch data from contentful graphql
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
graphql-job:
|
||||
fetch-data:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Run GraphQL query
|
||||
uses: octokit/graphql-action@v2.2.24
|
||||
- name: Fetch data from contentful graphql
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CONTENTFUL_URL: https://graphql.contentful.com/content/v1/spaces/ffrhttfighww/environments/master
|
||||
CONTENTFUL_TOKEN: ${{ secrets.CONTENTFUL_TOKEN }}
|
||||
with:
|
||||
query: |
|
||||
query($locale: String) {
|
||||
catalog(id: "2Yp0TY3kBHgG6VDjsHZNpK", locale: $locale) {
|
||||
linkedFrom(allowedLocales: ["en-US"]) {
|
||||
catalogCollection(limit: 20) {
|
||||
items {
|
||||
key
|
||||
position
|
||||
title
|
||||
linkedFrom(allowedLocales: ["en-US"]) {
|
||||
catalogCollection(limit: 20) {
|
||||
items {
|
||||
key
|
||||
title
|
||||
position
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOCALES: "en-US,zh-CN"
|
||||
run: |
|
||||
IFS=',' read -ra LOCALE_ARRAY <<< "$LOCALES"
|
||||
for LOCALE in "${LOCALE_ARRAY[@]}"; do
|
||||
curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
--data '{"query":"query($locale: String){catalog(id: \"2Yp0TY3kBHgG6VDjsHZNpK\",locale:$locale) {linkedFrom(allowedLocales:[\"en-US\"]) {catalogCollection(limit:20) {items {key position title linkedFrom(allowedLocales:[\"en-US\"]) {catalogCollection(limit:20) {items {key title position}}}}}}}}","variables":{"locale":"$LOCALE"}}' \
|
||||
https://graphql.contentful.com/content/v1/spaces/$SPACE_ID > appmanage/static/json/catalog_$LOCALE.json
|
||||
done
|
||||
|
||||
variables: |
|
||||
{
|
||||
"locale": "en-US"
|
||||
}
|
||||
headers: |
|
||||
{
|
||||
"Authorization": "Bearer $CONTENTFUL_TOKEN"
|
||||
}
|
||||
result-encoding: string
|
||||
result-path: appmanage/static/json/catalog.json
|
||||
- name: Commit and push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Update catalog.json
|
||||
|
|
Loading…
Reference in a new issue