fix(server): handle DownloadError and RequestError in server mode (#806) #659
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
name: Fetch product types | |
on: | |
workflow_dispatch: | |
push: | |
branches: [master, develop] | |
schedule: | |
- cron: "0 6 * * *" | |
jobs: | |
fetch-product-types: | |
name: Fetch providers for new product types | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Set up Python 3.7 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.7" | |
- name: Update pip | |
run: python -m pip install --upgrade pip | |
- name: Get pip cache dir | |
id: pip-cache | |
shell: bash | |
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Get current week number | |
id: get-week | |
shell: bash | |
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT | |
- name: Pip cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.DIR }} | |
key: ${{ runner.os }}-pip-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }} | |
- name: Install eodag | |
run: | | |
python -m pip install . | |
- name: Fetch and update external product types reference | |
run: | | |
export JSON_OUTPUT_FILE="eodag/resources/ext_product_types.json" | |
export JSON_REF_FILE=$(python -c "import eodag; print(eodag.config.EXT_PRODUCT_TYPES_CONF_URI)") | |
eodag -vvv discover --storage ${JSON_OUTPUT_FILE} | |
# add empty line at end of file | |
sed -i -e '$a\' ${JSON_OUTPUT_FILE} | |
git config user.name "github-actions[bot]" | |
git config user.email "'github-actions[bot]@users.noreply.github.com" | |
git add "${JSON_OUTPUT_FILE}" | |
git commit -m "fix: update external product types reference" || exit 0 | |
echo "Update external product types reference from daily fetch. See [Python API User Guide / Product types discovery](https://eodag.readthedocs.io/en/latest/notebooks/api_user_guide/2_providers_products_available.html#Product-types-discovery)" >> $GITHUB_STEP_SUMMARY | |
echo '### Changed files' >> $GITHUB_STEP_SUMMARY | |
echo 'May be truncated.' >> $GITHUB_STEP_SUMMARY | |
COMMIT_SHA=$(git rev-parse HEAD) | |
COMMIT_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${COMMIT_SHA}" | |
echo "commit [${COMMIT_SHA}](${COMMIT_URL})" >> $GITHUB_STEP_SUMMARY | |
echo '```diff' >> $GITHUB_STEP_SUMMARY | |
git show --name-only --format=tformat: >> $GITHUB_STEP_SUMMARY | |
(diff <(curl ${JSON_REF_FILE} | jq ) <(cat ${JSON_OUTPUT_FILE} | jq) || true) >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
# truncated PR body (too long causes error) | |
full_update_summary=$(cat $GITHUB_STEP_SUMMARY) | |
echo 'UPDATE_SUMMARY<<EOF' >> $GITHUB_ENV | |
echo "${full_update_summary:0:65536}" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
branch: external-product-types-ref-update | |
delete-branch: true | |
title: 'fix: update external product types reference' | |
body: ${{ env.UPDATE_SUMMARY }} | |
labels: | | |
automated pr |