Skip to content

Commit

Permalink
update workflow for schema-docs (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendhouseart authored Feb 2, 2023
1 parent 6f8b489 commit eb658db
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions .github/workflows/schema_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,51 @@ jobs:
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v3
with:
path: source
persist-credentials: false

- name: Debug
uses: mxschmitt/action-tmate@v3
if: ${{ inputs.debug_enabled }}
timeout-minutes: 15
- name: Collect schema-docs repo
uses: actions/checkout@v3
with:
limit-access-to-actor: true
ref: main
repository: ${{ github.repository_owner }}/schema-docs
path: dest
token: ${{ secrets.SCHEMA_DOCS_GITHUB_API_TOKEN }}
fetch-depth: 0
persist-credentials: true

- name: Update schema-docs from bids-specification
run: |
rsync --recursive --copy-links source/tools/schemacode/bidsschematools dest/
rsync --recursive --copy-links source/tools/schemacode/docs dest/
cat source/requirements.txt | grep -v tools/schemacode >> dest/requirements.txt
sort dest/requirements.txt | uniq > dest/requirements.txt.tmp
mv dest/requirements.txt.tmp dest/requirements.txt
- name: Pull schema-docs and reqs from bids-specification
- name: Check for Updates
id: updatesmade
working-directory: dest
run: |
pushd $HOME
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor}}@noreply.com"
git clone https://${{ github.repository_owner }}:${{ secrets.SCHEMA_DOCS_GITHUB_API_TOKEN }}@github.com/${{ github.repository_owner }}/schema-docs
popd
rsync --recursive --copy-links ${{ github.workspace }}/tools/schemacode/bidsschematools $HOME/schema-docs/
rsync --recursive --copy-links ${{ github.workspace }}/tools/schemacode/docs $HOME/schema-docs/
cat ${{ github.workspace }}/requirements.txt | grep -v tools/schemacode >> $HOME/schema-docs/requirements.txt
sort $HOME/schema-docs/requirements.txt | uniq > $HOME/schema-docs/requirements.txt.tmp
mv $HOME/schema-docs/requirements.txt.tmp $HOME/schema-docs/requirements.txt
- name: Push Updates to schema-docs
run: |
pushd $HOME/schema-docs
git diff --exit-code > $HOME/gitdiff.log
if [[ $? == 0 ]]; then
git add --all
git status --porcelain
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
echo "changesmade=true" >> $GITHUB_OUTPUT
else
echo "No changes found schema code, this workflow should only run when changes are made to schema-*."
echo "You must be up to no good."
else
git add --all
git commit -m "Auto update from bids-specification $GITHUB_SHA"
git push origin main
echo "changesmade=false" >> $GITHUB_OUTPUT
fi
- name: Push Updates
if: ${{ steps.updatesmade.outputs.changesmade == 'true' }}
working-directory: dest
env:
ACTOR: ${{ github.actor }}
OWNER: ${{ github.repository_owner }}
run: |
git config --global user.name "$ACTOR"
git config --global user.email "[email protected]"
git add --all
git commit -m "Auto update from bids-specification $GITHUB_SHA"
git push

0 comments on commit eb658db

Please sign in to comment.