Update getDatafromContentful.yml

This commit is contained in:
赵璟 2023-06-08 17:25:24 +08:00 committed by GitHub
parent 15307304cf
commit 19e404064d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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