run data fetching job #7286
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: run data fetching job | ||
env: | ||
PR_NUMBER: PR-${{ github.event.number }} | ||
DATA_DIR: data | ||
GITHUB_URL: https://mariloubylr:${{ secrets.GITHUB_TOKEN }}@github.com/mariloubylr/ci-magic.git | ||
on: | ||
workflow_run: | ||
workflows: ["build-frontend-main", "build-frontend-pr-pages"] | ||
types: | ||
- completed | ||
schedule: | ||
- cron: '*/6 * * * *' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repo content | ||
uses: actions/checkout@main # checkout the repository content | ||
- name: setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' # install python | ||
- run: | | ||
cd backend | ||
ls | ||
shell: bash | ||
- name: install python packages | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: execute python script # run main.py | ||
run: | | ||
python backend/fetch_data.py ${{env.DATA_DIR}} | ||
ls | ||
- name: Clone gh-pages repo | ||
run: | | ||
mkdir -p temp_build | ||
cd temp_build | ||
git init -q --initial-branch='gh-pages' | ||
git remote add origin ${{env.GITHUB_URL}} | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "mariloubylr" | ||
git config --local advice.skippedCherryPicks false # Disable messages to include skipped commits | ||
git pull -q origin gh-pages --rebase -X theirs > /dev/null | ||
ls | ||
- name: Sets env vars for prod | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
echo "DATA_TARGET=prod/data" >> $GITHUB_ENV | ||
- name: Sets env vars for PRs | ||
if: github.ref != 'refs/heads/main' | ||
run: | | ||
echo "DATA_TARGET=PR-${{ github.event.number }}/data" >> $GITHUB_ENV | ||
- name: Copy data into repo | ||
run: | | ||
echo $DATA_TARGET | ||
mkdir -p temp_build/$DATA_TARGET | ||
cp ${{env.DATA_DIR}}/* temp_build/$DATA_TARGET/ | ||
shell: bash | ||
- name: Commit Data | ||
run: | | ||
cd temp_build | ||
git add -A | ||
git status | ||
git commit -qm "update data to $DATA_TARGET" | ||
- name: Push Data | ||
if: ${{ git diff-index --quiet origin/gh-pages }} | ||
Check failure on line 74 in .github/workflows/fetch_data.yml GitHub Actions / run data fetching jobInvalid workflow file
|
||
run: | | ||
git push -qf origin gh-pages:gh-pages | ||
shell: bash |