0565a9db44f964c268bf387287240bbe5578b867 #424
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: update sdks | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
update_sdk: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
sdk: [['neurostore-python-sdk', 'python'], ['neurosynth-compose-python-sdk', 'python'], ['neurostore-typescript-sdk', 'typescript'], ['neurosynth-compose-typescript-sdk', 'typescript']] | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Checkout current SDK code | |
uses: actions/checkout@v3 | |
with: | |
repository: neurostuff/${{ matrix.sdk[0] }} | |
path: ${{ matrix.sdk[1] }}/${{ matrix.sdk[0] }} | |
- name: Checkout reciprical branch | |
run: | | |
cd ${{ matrix.sdk[1] }}/${{ matrix.sdk[0] }} | |
git fetch | |
git ls-remote --exit-code --heads origin ${{ github.ref_name }} || git branch ${{ github.ref_name }} | |
git checkout ${{ github.ref_name }} | |
- name: Generate SDK | |
run: | | |
./generate.sh ${{ matrix.sdk[0] }} | |
# - name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
# timeout-minutes: 45 | |
- name: Add and commit changes | |
run: | | |
cd ${{ matrix.sdk[1] }}/${{ matrix.sdk[0] }} | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git config --local --unset-all "http.https://github.com/.extraheader" | |
# check to see if there were any changes to the repository and no branches made | |
if [ -z "$(git ls-files --others --exclude-standard --directory --unmerged --modified)" ]; then | |
echo "No files to be committed!" | |
if [ -z "$(git ls-remote --heads origin ${{ github.ref_name }})" ]; then | |
git push -q https://${{ secrets.SDK_PAT }}@github.com/neurostuff/${{ matrix.sdk[0] }}.git ${{ github.ref_name }} | |
else | |
echo "branch already exists and is up to date" | |
fi | |
else | |
git add -A && git commit -m "${{ github.sha }}" -a | |
git push -q https://${{ secrets.SDK_PAT }}@github.com/neurostuff/${{ matrix.sdk[0] }}.git ${{ github.ref_name }} | |
fi |