Skip to content

Add changes

Add changes #1127

name: Transform
on:
push:
branches: [ trigger_branch ]
# The above does not work. Tried asking at https://github.community/t/push-to-branch-not-triggering-workflow/140508 .
workflow_dispatch:
inputs:
logLevel:
default: 'warning'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
# python-version: [3.5, 3.6, 3.7, 3.8]
steps:
- name: Check out trigger_branch
uses: actions/checkout@master
with:
# persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 1 # Because of this, you will fail to push refs to dest repo
ref: trigger_branch
- name: Check out ashtadhyayi-com/data
uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 1 # Because of this, you will fail to push refs to dest repo
repository: ashtadhyayi-com/data
ref: master
path: ashtadhyayi-com-data
- name: Check out master branch
uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 1 # Because of this, you will fail to push refs to dest repo
ref: master
path: master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python -m pip install git+https://github.com/ashtadhyayi/data_curation@master
- name: Create local changes
run: |
cp -rnf change_details master/
python -c "from ashtadhyayi_data.reader.ashtadhyayi_com.suutra import transformer; transformer.transform(indir=\"`pwd`/ashtadhyayi-com-data/\", outdir=\"`pwd`/master\", dry_run=False)"
- name: Commit files
env:
TRANSFORM_REPO_TOKEN: ${{ secrets.VISH_TOKEN }}
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd master
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add --all
git diff-index --quiet HEAD || git commit -m "Add changes" -a
remote_repo="https://${GITHUB_ACTOR}:${REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push "${remote_repo}" HEAD:master|| (cd .. && git pull --rebase && git commit --allow-empty -m "Dummy commit to trigger workflow rerun upon 'push race condition'." && git push "https://${GITHUB_ACTOR}:${TRANSFORM_REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:trigger_branch)