[MNT] Automated generation of result examples #25
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 examples | |
on: | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
generate-example-files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up node env | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Create .env file | |
run: | | |
echo -e "NB_API_QUERY_URL=https://federate.neurobagel.org/\nNB_ENABLE_AUTH=true\nNB_QUERY_CLIENT_ID=mockclientid" > .env | |
- name: build | |
run: npm install && npm run build | |
- name: Run end to end tests | |
uses: cypress-io/github-action@v6 | |
with: | |
wait-on: http://localhost:5173 | |
start: npm run preview | |
spec: cypress/e2e/UpdateExamples.cy.ts | |
component: false | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: query-tool-results | |
path: cypress/downloads/* | |
update-query-tool-results: | |
runs-on: ubuntu-latest | |
needs: generate-example-files | |
steps: | |
- name: Generate a token | |
id: generate-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ vars.NB_BOT_ID }} | |
private-key: ${{ secrets.NB_BOT_KEY }} | |
- name: Checkout neurobagel_examples repository | |
uses: actions/checkout@v4 | |
with: | |
repository: neurobagel/neurobagel_examples | |
token: ${{ steps.generate-token.outputs.token }} | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: query-tool-results | |
path: neurobagel_examples/query-tool-results | |
- name: Install GitHub CLI | |
run: sudo apt-get install gh -y | |
- name: Authenticate GitHub CLI | |
run: echo "${{ steps.generate-token.outputs.token }}" | gh auth login --with-token | |
- name: Create Pull Request | |
run: | | |
git config --global user.name "Neurobagel Bot" | |
git config --global user.email "neurobagel-bot[bot]@users.noreply.github.com" | |
git checkout -b update-query-tool-results | |
git add . | |
git commit -m "Update query-tool-results files" | |
git push origin update-query-tool-results | |
gh pr create --title "Update query-tool-results files" --body "This PR updates the query-tool-results files with the latest changes." --base main --head update-query-tool-results |